结果示例:
学号:2022
年龄 性别 学历 工作经验 期望工资
40 男 高中 1-3年 3000-5000
关注【以下回答由 GPT 生成】
我可以使用Python的requests和BeautifulSoup库来抓取58同城招聘页的信息。以下是具体的解决方案。
首先,我们需要安装需要的库。可以使用以下命令来安装:
pip install requests
pip install beautifulsoup4
接下来,我们可以编写Python代码来实现抓取招聘页信息的功能。代码如下:
import requests
from bs4 import BeautifulSoup
def scrape_58_recruitment(url):
# 发起GET请求获取页面内容
response = requests.get(url)
if response.status_code == 200:
# 使用BeautifulSoup解析页面内容
soup = BeautifulSoup(response.text, 'html.parser')
# 定位到招聘信息的列表
recruitment_list = soup.select('.job_list li')
# 遍历招聘信息列表并输出每个招聘信息的相关字段
for recruitment in recruitment_list:
age = recruitment.select_one('.age').text.strip()
gender = recruitment.select_one('.sex').text.strip()
education = recruitment.select_one('.education').text.strip()
experience = recruitment.select_one('.experience').text.strip()
salary = recruitment.select_one('.salary').text.strip()
print(f"年龄:{age} 性别:{gender} 学历:{education} 工作经验:{experience} 期望工资:{salary}")
else:
print("请求失败")
# 调用函数来抓取招聘页信息
url = "https://hy.58.com/qzshichangdiaoyan/?PGTID=0d202409-0039-21b3-247d-1acd086d8b1d&ClickID=12"
scrape_58_recruitment(url)
以上代码会发起GET请求,获取页面内容并使用BeautifulSoup解析页面。然后,我们定位到招聘信息列表,并遍历列表中的每个招聘信息,提取年龄、性别、学历、工作经验和期望工资等字段,并输出结果。
请注意,由于网页结构的变化或其他原因,代码可能需要进行适当的调整才能正确抓取信息。
希望这个解决方案对你有帮助!如果你还有任何问题,请随时提问。
【相关推荐】