######################首先使用requests获取前程无忧一级网页
import requests
from lxml.etree import HTML
import re
import time
page=1
while True:
url=‘https://search.51job.com/list/020000,000000,0000,01,2,99,%2B,2,{
}.html?lang=c&stype=1&postchannel=0000&workyear=99&cotype=99°reefrom=99&jobterm=99&companysize=99&lonlat=0%2C0&radius=-1&ord_field=0&confirmdate=9&fromType=5&dibiaoid=0&address=&line=&specialarea=00&from=&welfare=’
try:
rst=requests.get(url.format(page))
rst.apparent_encoding
rst.encoding=‘GB2312’
rst=rst.text
html=HTML(rst)
ls=html.xpath(’//[@id=“resultList”]/div[.]/p/span/a/@href’) #Xpath获取所有岗位的url
tatal=re.compile('共(.?)页’).findall(rst) #正则获取总页数
tatal=int(tatal[0])
#######
python爬取前程无忧招聘岗位信息
最新推荐文章于 2025-06-16 17:46:02 发布