当前位置: 首页 > 后端技术 > Python

用python爬上了厦门人才网的.net位置

时间:2023-03-26 19:06:16 Python

为了看看.net的就业市场如何,我用python在厦门人才网上爬取了.net的招聘信息。关于代码,我没有说太多。好久没学python了。如有不妥请指正importrequestsfrombs4importBeautifulSouppage=1;defloop(page):url="https://www.xmrc.com.cn/net/info/resultg.aspx?a=a&g=g&jobtype=&releaseTime=365&searchtype=1&keyword=.net&sortby=updatetime&ascdesc=Desc&PageIndex=%s"%page;response=requests.get(url)soup=BeautifulSoup(response.text,'html.parser')allJob=soup.select(".a4.js_companyName");公司=[]其他=[]forxinrange(0,len(allJob)):job=allJob[x].get_text().strip()print(job);其他=allJob[x].parent.findPrevious("td").get_text().strip()+","+allJob[x].parent.findNext("td").get_text().strip()+","+allJob[x].parent.findNext("td")。findNext("td").get_text().strip();打印(其他);companies.append(job)Others.append(other)returncompanys,Others;forxinrange(0,20):companys,Others=loop(x)withopen('company.txt','a',encoding='utf-8')asf:forxinrange(0,len(companys)):f.write(str(公司[x]+","+其他[x])+'\n')