import requests
from lxml import etree
import chardet
def getjoblist(url):
response = requests.get(url)
encoding = chardet.detect(response.content)['encoding']
if encoding and encoding != 'utf-8':
response.encoding = encoding
html = etree.HTML(response.text)
title = html.xpath('//a[@class="jobNameCon"]/text()')
print(title)
href = html.xpath('//a[@class="jobNameCon"]/@href')
print(href)
salaryList = html.xpath('//span[@class="salaryList"]/text()')
print(salaryList)
if __name__ == '__main__':
url='https://www.job001.cn/jobs?keyType=1&keyWord=ai&jobTypeId=&jobType=%E8%81%8C%E4%BD%8D%E7%B1%BB%E5%9E%8B&industry=&industryname=%E8%A1%8C%E4%B8%9A%E7%B1%BB%E5%9E%8B&workId=&workPlace=&salary=&salaryType=&entType=&experience=&education=&entSize=&benefits=&reftime=&workTypeId=&sortField=&pageNo=1&curItem=&searchType=1'
getjoblist(url)