zoukankan      html  css  js  c++  java
  • 爬虫之爬取求职小网站

    
    

    import requests
    form bs4 import BeautifulSoup



    爬取实习生的网站 https:
    //www.shixiseng.com/it/2 def translate_number(s): s = s.encode("utf-8") s = s.replace(b"xeex83x88",b"0")#字符串替换 将二进制数据替换成数字 s = s.replace(b"xeexbbx85",b"1")#字符串替换 s = s.replace(b"xefx8bx85",b"2")#字符串替换 s = s.replace(b"xeex8fxbe",b"3")#字符串替换 s = s.replace(b"xeexb8xae",b"4")#字符串替换 s = s.replace(b"xeex96x83",b"5")#字符串替换 s = s.replace(b"xefx86xb1",b"6")#字符串替换 s = s.replace(b"xefx91xa8",b"7")#字符串替换 s = s.replace(b"xefx8ax9b",b"8")#字符串替换 s = s.replace(b"xefx9bxbb",b"9")#字符串替换 return s.decode("utf-8") def url(): req = requests.get(url) html = req.text#获取标签中的文本值 soup = BeautifulSoup(html,"lxml") job_name = soup.select(".new_job_name“)[0].string company_name = soup.select(".job_com_name")[0].string job_position = soup.select(".job_position")[0].string job_academic = soup.select(".job_academic")[0].string job_money = translate_number(soup.select(".job_money")[0].string.encode("utf-8")) print(job_money) print("职位:{},公司:{},地点:{},学历:{},薪资:{}”.format(job_name,conpany_name,job_position,job_academic,job_money) for page in range(20): #输入需要爬取的网站网址来进行爬取 rep = requests.get("https://www.shixiseng.com/it/2".format(page)) html = req.text#获取标签中的文本值 soup= BeautifulSoup(html,"lxml") for job in soup.select("a.name") url = job.get("herf") print(url) detail_page("https://www.shixiseng.com"+detail_url)
  • 相关阅读:
    微服务、SpringCloud、k8s、Istio杂谈
    php环境安装
    最近重构公司消息服务的架构设计
    test
    博文目录(最新更新:2019.8.5)
    读过的书
    我在北京这几年(全)
    【原】深度学习的一些经验总结和建议 | To do v.s Not To Do
    如何高效利用一场技术分享?
    深度学习分布式训练及CTR预估模型应用
  • 原文地址:https://www.cnblogs.com/tangda/p/10824273.html
Copyright © 2011-2022 走看看