基于requests的51job数据爬取并存储到csv中

该博客介绍了如何利用requests库下载51job网站的数据,并进行解析,最终将数据存储到CSV文件中,提供了完整的代码示例链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

import requests
from fake_useragent import UserAgent
agent=UserAgent()
#当用到xpath时需要引入此包
from lxml import etree

下载

url="http://search.51job.com/list/010000%252C020000%252C180200%252C200200,000000,0000,00,9,99,python,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="

response = requests.get(url,
                                          headers = {"User-Agent":agent.random},
                      )
#设置编码格式
response.encoding=response.apparent_encoding

解析

# root可理解为网页本身
root = etree.HTML(response.text)
#用xpath返回的是一个列表
div_list = root.xpath('//div[@class="dw_t
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值