python3爬取百度招聘信息使用进程池
来源:互联网 发布:淘宝店铺打印快递单 编辑:程序博客网 时间:2024/04/28 21:06
# encoding:utf-8import json # 使用json解码 因为百度招聘信息是json格式import requests # 使用requests找到网页源代码import pandas # 使用pandas存数据from bs4 import BeautifulSoup # 使用beautifulsoup解析你要找的数据from multiprocessing import Pool # 使用进程池
def content(i): # 代码测试中传入的url链接 # 你的请求头信息 head = {'User-Agent': 'Mozilla/5.0'} # 你的url链接 这里使用了format拼接 获取的是前五页的内容 url = 'http://talent.baidu.com/baidu/web/httpservice/getPostList?postType=&workPlace=0%2F4%2F7%2F9&recruitType=2&keyWord=python&pageSize=10&curPage={}&_=1498042913789'.format(i) # 得到传入的链接 把请求头加上 得到文本格式 request = requests.get(url, headers=head).text # 使用json.loads进行解码 因为这个网页是json格式的 dj = json.loads(request) lis = [] # 定义空列表是为了接收你得到的数据 for i in range(10): # 这个循环是通过下标得到里面的内容 item = [] # 定义空列表接受你这个循环里面的数据 # 下面有图片 大家可以看看这个列表里面追加的是什么内容 item.append(dj['postList'][i]['name']) item.append(dj['postList'][i]['postType']) item.append(dj['postList'][i]['publishDate']) item.append(dj['postList'][i]['recruitNum']) item.append(dj['postList'][i]['serviceCondition']) item.append(dj['postList'][i]['workContent']) item.append(dj['postList'][i]['workPlace']) return lis.append(item) # 使用pandas把你得到的数据放入到你定义的百度.xlsx data = pandas.DataFrame(lis) data.to_excel('百度.xlsx')
# 代码测试if __name__=='__main__': # 传入5个值 group =[i for i in range(5)] loo = Pool(2) # 创建进程池 这个里面的数据指的是你的内核 loo.map(content, group) # 把这个列表放入进程池中
大家多评论指正
阅读全文
1 0
- python3爬取百度招聘信息使用进程池
- python3爬取使用BeautifulSoup爬取前程无忧的python招聘信息入库MongoDB!
- python3 [爬虫入门实战] 爬虫之使用selenium 爬取百度招聘内容并存mongodb
- 爬取招聘信息
- python3小项目——爬取招聘信息(智联招聘)
- Python3 爬取百度百科
- 使用BS4爬取 51job 一页的招聘信息
- 使用Scrapy框架爬取腾讯招聘信息
- python3爬取淘宝信息
- python3爬取淘宝信息!
- python3爬取猫眼电影(电影名称和图片)存到本地使用进程池
- Python3 根据关键字爬取百度图片
- 利用Python3爬取百度贴吧
- Python3爬取百度贴吧网页
- 百度道路信息爬取
- java使用htmlunit爬取百度搜索信息
- python3 爬取学校口语坊信息
- 百度console招聘信息
- 排列组合 Shaass and Lights:CodeForces
- java基础篇《4》--条件结构
- 搭建简易Web GIS网站:使用GeoServer+PostgreSQL+PostGIS+OpenLayers3
- 9. Palindrome Number-python
- 线程池总结
- python3爬取百度招聘信息使用进程池
- java-xml-singleton
- webpack 初识
- 从最简单的vector中sort用法到自定义比较函数comp后对结构体排序的sort算法
- stray '\\241' in program
- (OK) quagga
- 欢迎使用CSDN-markdown编辑器
- 安卓开发——显示网速
- Android dumpstate 工具解析