Python助力2020高校應屆生就業 獲取2020校園招聘信息

概述app

因爲疫情的緣由,你們都在家待着,若是你是應屆生的話,那麼對於找工做可能會有點迷茫,所以小編從網上弄了一部分招聘信息以供使用。ide

項目總述url

整個項目依舊很簡單,主要是獲取數據比較麻煩,至於流程,詳見幾十行代碼批量下載高清壁紙 爬蟲入門實戰spa

部分代碼code

此次我只分爲了兩部分。blog

1.從主頁獲取各個專業對應的url列表get

# 1.獲取各個專業對應的url列表
index_data = requests.get(index_url, headers=headers).content.decode('gbk', 'ignore')
tree = etree.HTML(index_data)
second_data = tree.xpath(".//ul[@class='s_clear']/li/a/@href")[0:33]
major_name = tree.xpath(".//ul[@class='s_clear']/li/a/text()")[0:33]
major_url = []
for one_third_url in second_data:
    x = str(one_third_url).split(".", 2)[1]
    major_url.append(x)

2.獲取各個目錄下的崗位列表requests

# 獲取各個專業目錄下的崗位
for i in range(len(major_url)):
    print(major_url[i])
    print(major_name[i])
    major_job_page = requests.get(major_url[i], headers=headers).content.decode('gbk', 'ignore')
    major_job_page_tree = etree.HTML(major_job_page)
    job_list_title = major_job_page_tree.xpath(".//div[@class='hotJobList']/div/ul/li/a/text()")
    job_list_url = major_job_page_tree.xpath(".//div[@class='hotJobList']/div/ul/li/a/@href")
    job_list_date = major_job_page_tree.xpath(".//div[@class='hotJobList']/div/ul/li/span/text()")

結果展現it

Python助力2020高校應屆生就業 獲取2020校園招聘信息

相關文章
相關標籤/搜索