import requests
#from bs4 import BeautifulSoup
from lxml import etree
#//*[@id="resultList"]/div[4]/p/span/a 第一条职位
#//*[@id="resultList"]/div[4]/span[1]/a 第一条公司
#//*[@id="resultList"]/div[4]/span[3] 第一条薪资
url='https://search.51job.com/list/000000,000000,0000,00,9,99,%2520,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='
res=requests.get(url)
res.encoding = res.apparent_encoding
html=etree.HTML(res.text)
name=html.xpath("//*[@id='resultList']/div/p/span/a/text()")
names=[]
coms=[]
salarys=[]
for i in range(50):
name=html.xpath("//*[@id='resultList']/div[{}]/p/span/a/text()".format(4+i))[0].strip()#for循环来爬xpath!!!
com=html.xpath("//*[@id='resultList']/div[{}]/span[1]/a/text()".format(4+i))[0].strip()
salary=html.xpath("//*[@id='resultList']/div[{}]/span[3]/text()".format(4+i))
names.append(name)
coms.append(com)
salarys.append(salary)
for i in range(len(names)):
print("{} {} {}".format(names[i],coms[i],salarys[i]))