2301_80358763 2023-10-17 16:36 采纳率: 0%
浏览 11

到底怎么做啊?有没有人会?

抓取58同城招聘页(https://hy.58.com/qzshichangdiaoyan/?PGTID=0d202409-0039-21b3-247d-1acd086d8b1d&ClickID=12)显示以下信息,将代码与结果放入答案中,第1行为本人学号

结果示例:

学号:2022

年龄 性别 学历 工作经验 期望工资

40 男 高中 1-3年 3000-5000

  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2023-10-18 04:20
    关注

    【以下回答由 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解析页面。然后,我们定位到招聘信息列表,并遍历列表中的每个招聘信息,提取年龄、性别、学历、工作经验和期望工资等字段,并输出结果。

    请注意,由于网页结构的变化或其他原因,代码可能需要进行适当的调整才能正确抓取信息。

    希望这个解决方案对你有帮助!如果你还有任何问题,请随时提问。



    【相关推荐】



    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

问题事件

  • 创建了问题 10月17日