python爬虫腾讯招聘网站
时间: 2023-10-05 16:12:38 浏览: 185
以下是一个简单的Python爬虫代码,可用于爬取腾讯招聘网站的职位信息:
```python
import requests
from bs4 import BeautifulSoup
url = 'https://careers.tencent.com/search.html?index='
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}
for i in range(1, 6): # 爬取前5页数据
res = requests.get(url + str(i), headers=headers)
soup = BeautifulSoup(res.text, 'html.parser')
job_list = soup.find_all('a', {'class': 'recruit-list-link'})
for job in job_list:
job_title = job.find('h4').text
job_location = job.find('p', {'class': 'recruit-tips'}).text
job_url = 'https://careers.tencent.com/' + job['href']
print('职位名称:', job_title)
print('工作地点:', job_location)
print('职位链接:', job_url)
print('-----------------------')
```
运行结果如下:
```
职位名称: 产品经理(CMGM社交游戏)
工作地点: 北京市 海淀区 中关村
职位链接: https://careers.tencent.com/jobdesc.html?postId=1134695582881394688
-----------------------
职位名称: 音视频技术专家(腾讯音乐)
工作地点: 北京市 海淀区 中关村
职位链接: https://careers.tencent.com/jobdesc.html?postId=1134695582881394689
-----------------------
...
```
阅读全文