利用python爬取实习僧网站上的数据
来源:互联网 发布:java snmp agent 编辑:程序博客网 时间:2024/05/22 06:29
最近在找实习,就顺便想到用python爬取一些职位信息看看,有哪些岗位比较缺人。
#_*_coding:utf-8_*_import requestsfrom bs4 import BeautifulSoupimport xlwtimport rebook = xlwt.Workbook()#创建表格sheet = book.add_sheet('sheet1', cell_overwrite_ok=True)def getHtml(): url ='http://www.shixiseng.com/interns?p=' request = requests.get(url=url) respons = request.content #得到页面源代码 soup = BeautifulSoup(respons,'html.parser') #解析源代码 #下面是计算岗位列表的页数 page=soup.select('div#pagebar')[0] l=str(page.select('li')[-1].a.attrs['href']) x=re.compile(r'\d{3}') y=x.search(l) lastpage=int(y.group()) print lastpage #调用函数 saveData(url,lastpage + 1)def saveData(url,lastpage): row=0 #必须定义为全局变量 for i in range(1,lastpage): html = requests.get(url='%s%d' % (url,i)).content soup = BeautifulSoup(html,'html.parser') infos = soup.select('div.posi-list')[0].select('div.list') #相关的数据信息 for info in infos: po_name = info.select('div.names.cutom_font')[0].a.text part = info.find('a', class_='cutom_font').text addr = info.find('div', class_='addr').span.text xz = info.find('div', class_='xz').span.text #写入excel sheet.write(row, 0, po_name) sheet.write(row, 1, part) sheet.write(row, 2, addr) sheet.write(row, 3, xz) row+=1if __name__ == '__main__': getHtml() book.save('shixiseng.xls')
阅读全文
1 0
- 利用python爬取实习僧网站上的数据
- 利用Python爬取YouTube上的视频播放地址
- 利用 Python 爬取豆瓣电影排行榜 Top250 的数据
- 利用python爬取人人贷网的数据
- python爬取网站数据保存使用的方法
- 爬取实习僧网站并存储到MongoDB
- Python利用BeautifulSoup4爬取账号共享网站的vip账户
- 利用爬虫爬取看看豆网站站的数据信息
- 爬虫-爬取网站上的图片
- python网络数据采集学习范例—利用CSS爬取网站特定标签,BeautifulSoup函数介绍及子标签
- Python爬取www.alexa.cn网站上的部分url和相应的等级
- python爬取并下载一个俄语植物网站上的图片
- Python运用urllib2和BeautifulSoup爬取网站ZOL桌面壁纸上的精美电脑壁纸
- [python] 爬取网站所有的URL
- [python] 爬取网站所有的URL
- 用Python 的 Scrapy 爬取 网站
- 爬取需要登录的网站数据
- 利用python爬取58同城简历数据
- MYSQL日期和时间函数
- EffectiveC++学习笔记-条款18|19
- ES6 的变量对象解构
- The source file name(s) are larger than is supported by the file system
- android单例模式的用途
- 利用python爬取实习僧网站上的数据
- CSU 1809 Parenthesis
- 统计词性语料库
- Java经典面试题
- wireshark 过滤规则语法
- Deepin配置AndroidStudio快捷方式
- weblogic 修改端口后停服务的时候提示错误
- ActiveMQ持久化消息的三种方式
- Java中除数0