美文网首页
python爬取招聘信息

python爬取招聘信息

作者: __豆约翰__ | 来源:发表于2018-12-17 21:09 被阅读80次
    import requests
    from bs4 import BeautifulSoup
    import time
    import random
    
    # 设置header
    header = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0',
            'Connection': 'keep - alive'
            }
    movie_list = []
    
    def get_pages_link():
        # https://movie.douban.com/top250?start=25
        for item in range(1,25,1):
            url = "https://www.liepin.com/zhaopin/?init=-1&headckid=8b8a11cc05e34e78&fromSearchBtn=2&ckid=8b8a11cc05e34e78&degradeFlag=0&key=python&siTag=I-7rQ0e90mv8a37po7dV3Q~fA9rXquZc5IkJpXC-Ycixw&d_sfrom=search_industry&d_ckId=ac6bf5fc984fbad69fd09f0270ca7f1f&d_curPage=0&d_pageSize=40&d_headId=ac6bf5fc984fbad69fd09f0270ca7f1f&curPage={}".format(item)
            web_data = requests.get(url,headers=header)
            time.sleep(1 + random.random())
            soup = BeautifulSoup(web_data.text,'lxml')
            for item in soup.select('.sojob-list li'):
                job = item.select('.job-info h3 a')[0].get_text().strip()
                condition = item.select('.condition')[0].get_text()
                (salary,addr,edu,experence) = condition.split()
                print(job)
                print(salary)
                print(addr)
                print(edu)
                print(experence)
                date = item.select('time')[0].attrs['title']
                print(date)
                company = item.select('.company-name')[0].get_text().strip()
                print(company)
                field = item.select('.field-financing')[0].get_text().strip()
                print(field)
                node = item.select('.temptation')
                if node:
                    temptation = item.select('.temptation')[0].get_text().strip()
                    print(temptation)
                print('-' * 20)
            print('\n'+' - '*50+'\n')
    
    if __name__ =='__main__':
        get_pages_link()
    
    
    

    相关文章

      网友评论

          本文标题:python爬取招聘信息

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