美文网首页
Python爬虫实战5

Python爬虫实战5

作者: python小哥哥2020 | 来源:发表于2022-03-19 17:11 被阅读0次
    import requests
    from bs4 import BeautifulSoup
    
    headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0',
             'Cookie':'jobui_p=1588600609732_82812311; TN_VisitCookie=65; Hm_lvt_8b3e2b14eff57d444737b5e71d065e72=1588640833,1588641001,1588641152,1588642264; jobui_area=%25E8%258B%258F%25E5%25B7%259E; jobui_user_passport=yk158860070505234; job-subscribe-guide=1; TN_VisitNum=51; Hm_lpvt_8b3e2b14eff57d444737b5e71d065e72=1588642691; PHPSESSID=btjbrtg3e7j2ib7mrdsbcv6co0'
             }
    url='https://www.jobui.com/rank/company/'
    res=requests.get(url,headers=headers)
    print(res.status_code)
    soup=BeautifulSoup(res.text,'html.parser')
    item=soup.find('div',class_='searchCont')
    list0=item.find_all('li')
    
    for shuju in list0:
        a=shuju.find('a')
        gongsi=a['title']
        wangzhi=a['href']
        link='https://wwww.jobui.com'+wangzhi+'jobs'
    
        res1=requests.get(link,headers=headers)
        soup1=BeautifulSoup(res1.text,'html.parser')
        items=soup1.find('div',id='companyJobsJobList')
        try:
            list1=items.find_all('div',class_='c-job-list')
            for list in list1:
                zhiwei=list.find('a',class_='job-name')['title']
                address=list.find('div',class_='job-desc').find_all('span')
                didian=address[0]['title']
                yaoqiu=address[1]['title']
                print(gongsi,zhiwei,didian,yaoqiu)
        except AttributeError:
            pass
    
    

    相关文章

      网友评论

          本文标题:Python爬虫实战5

          本文链接:https://www.haomeiwen.com/subject/xyhfdrtx.html