简单爬虫+pyecharts分析前途无忧招聘职位数量

爬虫+pyecharts分析前途无忧招聘职位数量

关于pyecharts的安装与使用可参考:http://pyecharts.org/#/zh-cn/intro

代码如下

from pyecharts.charts import Bar
from pyecharts import options as opts
import requests
from urllib import parse
import urllib
import re

def oneparse(oneurl):
    oneurls = 'https://search.51job.com/list/030200%252C040000,000000,0000,00,9,99,{},2,1.html?'

    response = requests.get(oneurls.format(oneurl))
    html = response.content.decode("gbk")
    oneSL = re.findall('共(.*?)条职位',html)[0]
    print(oneSL)
    SL_list.append(oneSL)
   

def twoparse(twourl):
    twourls = 'https://search.51job.com/list/030200%252C040000,000000,0000,00,9,99,{},2,1.html?'

    response = requests.get(twourls.format(twourl))
    html = response.content.decode("gbk")
    twoSL = re.findall('共(.*?)条职位',html)[0]
    print(twoSL)
    SL_list.append(twoSL)


def threeparse(threeurl):
    threeurls = 'https://search.51job.com/list/030200%252C040000,000000,0000,00,9,99,{},2,1.html?'

    response = requests.get(threeurls.format(threeurl))
    html = response.content.decode("gbk")
    threeSL = re.findall('共(.*?)条职位',html)[0]
    print(threeSL)
    SL_list.append(threeSL)


def fourparse(foururl):
    foururls = 'https://search.51job.com/list/030200%252C040000,000000,0000,00,9,99,{},2,1.html?'

    response = requests.get(foururls.format(foururl))
    html = response.content.decode("gbk")
    fourSL = re.findall('共(.*?)条职位',html)[0]
    print(fourSL)
    SL_list.append(fourSL)



if __name__ == '__main__':
    SL_list = []
    onename = str(input())
    twoname = str(input())
    threename = str(input())
    fourname = str(input())

    oneurl = urllib.parse.quote(onename)
    twourl = urllib.parse.quote(twoname)
    threeurl = urllib.parse.quote(threename)
    foururl = urllib.parse.quote(fourname)

    oneparse(oneurl)
    twoparse(twourl)
    threeparse(threeurl)
    fourparse(foururl)

    name=[onename, twoname, threename, fourname]
    bar = Bar()
    bar.add_xaxis(name)
    bar.add_yaxis("前途无忧", SL_list)
    bar.set_global_opts(title_opts=opts.TitleOpts(title="广州+深圳的职位数量"))
    bar.render()

运行结果
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值