抓取51job

视频地址 https://www.bilibili.com/video/av31369828?t=39&p=7
主要代码如下

#encoding:utf-8
#随便找一个就可以,因为现在这个67就是我搜索的python,但是格式真的没变

import selenium #测试框架
import selennium.webdriver #模拟浏览器
import re

mystr = """<div class = "rt">
  共67条职位
  <\div>"""


def getnumberbyname(searchname): #可能这里有一些混乱,手头没有python环境就没测试,大致就先这样吧
 url="https://search.51job.com/list/240200,000000,0000,00,9,99,"+searchname +",2,1.htmllang=c&stype=&postchannel=0000&workyear=99&cotype=99&degefrom=99&jobterm=99&companysize=99&providesalary=99&lonlat=0%2C0&adius=-1&ord_field=0&confirmdate=9&fromType=&dibiaoid=0&address=&lin=&specialarea=00&from=&welfare=
 driver = selenium.webdriver.Firefox() #调用火狐浏览器
 driver.get(url) #访问链接
 pagesource = driver.page_source #抓取网页源代码
 restr = """(\\d+)""" #先抓大,再抓小;尤其是空白字 符出现的时候
 regex = re.compile(restr, re.IGNORECASE)
 mylist = regex.findall(pagesource)
 newstr = mylist[0].strip()
 driver.close()#关闭
 return mylist[0]

pythonlist = ["python", "python 运维", "python 测试", "python 数据", "python web"]
for oystr in pythonlist:
  print pystr, getnumberbyname(pystr)
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容