import urllib.request
import re
url = "https://search.51job.com/list/150200,000000,0000,00,9,99,java,2,1.html?lang=c&stype=&postchannel=0000&workyear=99&cotype=99°reefrom=99&jobterm=99&companysize=99&providesalary=99&lonlat=0%2C0&radius=-1&ord_field=0&confirmdate=9&fromType=&dibiaoid=0&address=&line=&specialarea=00&from=&welfare="
def query(url):
html = ""
try:
response = urllib.request.urlopen(url)
html = str(response.read().decode("gbk"))
except:
print("access error")
restr = """<div class="rt">([\s\S]*?)</div>"""
regex = re.compile(restr, re.IGNORECASE)
mylist = regex.findall(html)
# 數據包含換行空格等字符
data = mylist[0].strip()
print(data)
# 提取職位數
restr = "(\\d+)"
regex = re.compile(restr, re.IGNORECASE)
mylist = regex.findall(data)
print(mylist[0])
query(url)
從51job提取職位數量
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.