python爬取腾讯招聘网
时间: 2023-11-17 07:06:34 浏览: 154
腾讯招聘信息的爬取
以下是使用Python爬取腾讯招聘网的示例代码:
```python
import requests
from bs4 import BeautifulSoup
url = 'https://careers.tencent.com/search.html?index=1'
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'}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
job_list = soup.find_all('a', class_='recruit-list-link')
for job in job_list:
print(job.text.strip())
```
这段代码使用requests库向腾讯招聘网发送请求,并使用BeautifulSoup库解析HTML页面。然后,它查找所有class为“recruit-list-link”的链接,并打印出它们的文本内容。
阅读全文