python爬取前程无忧
时间: 2023-10-05 08:14:30 浏览: 113
可以使用 Python 中的 requests 和 BeautifulSoup 库来爬取前程无忧网站的数据。以下是一个简单的示例代码,可以获取前程无忧网站上的某个职位的招聘信息:
```python
import requests
from bs4 import BeautifulSoup
url = 'https://search.51job.com/list/000000,000000,0000,00,9,99,Python%2B%E5%BC%80%E5%8F%91%2B%E5%B7%A5%E7%A8%8B%2B%E5%B7%A5%E7%A7%8D%2C2,{page}.html'
for page in range(1, 3): # 爬取前两页的数据
res = requests.get(url.format(page=page))
soup = BeautifulSoup(res.text, 'html.parser')
job_list = soup.select('.dw_table .el')
for job in job_list:
job_name = job.select('.t1')[0].text.strip()
company_name = job.select('.t2')[0].text.strip()
job_address = job.select('.t3')[0].text.strip()
salary = job.select('.t4')[0].text.strip()
publish_date = job.select('.t5')[0].text.strip()
print(job_name, company_name, job_address, salary, publish_date)
```
以上代码会爬取前程无忧网站上 Python 开发工程师的招聘信息,并输出职位名称、公司名称、工作地点、薪资和发布日期等信息。可以根据需要修改搜索关键词和爬取页数等参数。
阅读全文
相关推荐
















