加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

Python or Java?大数据解读学什么语言最赚钱

发布时间:2018-08-30 11:05:19 所属栏目:教程 来源:徐涛
导读:本文首要用Python爬取拉勾网差异编程说话地位信息,包罗:Python岗、Java岗、C++岗、PHP岗、C#岗亭(5岗);用R说话对影响薪资的身分举办说明。因为拉勾网的地位信息只表现30页,一页15个地位信息,假如单独爬取一个都市的岗亭信息,只有几页是匹配的信息,信
副问题[/!--empirenews.page--]

本文首要用Python爬取拉勾网差异编程说话地位信息,包罗:Python岗、Java岗、C++岗、PHP岗、C#岗亭(5岗);用R说话对影响薪资的身分举办说明。因为拉勾网的地位信息只表现30页,一页15个地位信息,假如单独爬取一个都市的岗亭信息,只有几页是匹配的信息,信息量太小,说明没有说服力。因此,本文爬取拉勾网世界地位信息。首要三部门内容:

  1. 爬取拉勾网5岗地位信息--以Python岗为例
  2. 以Python岗亭信息为例,说明影响薪资的身分
  3. 5岗之间薪水身分影响较量说明

一、爬取拉勾网5岗地位信息--以Python岗为例

我们抓取的信息包罗Python岗亭名称、公司名称、薪资、事变履历、学历、公司局限、公司福利。

Python or Java?大数据解读学什么说话最赚钱

  1. ##以python岗亭为例,运用selenium+Chrome()爬取岗亭信息 
  2. # coding=UTF-8 
  3. from lxml import etree 
  4. from selenium import webdriver 
  5. import time 
  6. import csv 
  7.  
  8. browser = webdriver.Chrome() 
  9. browser.get('https://www.lagou.com/jobs/list_PYTHON?px=default&city=%E5%85%A8%E5%9B%BD#filterBox') 
  10. browser.implicitly_wait(10) 
  11.  
  12. def get_dates(selector): 
  13.         items = selector.xpath('//*[@id="s_position_list"]/ul/li') 
  14.         for item in items: 
  15.             yield { 
  16.                 'Name': item.xpath('div[1]/div[1]/div[1]/a/h3/text()')[0], 
  17.                 'Company': item.xpath('div[1]/div[2]/div[1]/a/text()')[0], 
  18.                 'Salary': item.xpath('div[1]/div[1]/div[2]/div/span/text()')[0], 
  19.                 'Education': item.xpath('div[1]/div[1]/div[2]/div//text()')[3].strip(), 
  20.                 'Size': item.xpath('div[1]/div[2]/div[2]/text()')[0].strip(), 
  21.                 'Welfare': item.xpath('div[2]/div[2]/text()')[0] 
  22.             } 
  23. def main(): 
  24.     i = 0 
  25.     for i in range(30): 
  26.         selector = etree.HTML(browser.page_source) 
  27.         browser.find_element_by_xpath('//*[@id="order"]/li/div[4]/div[2]').click() 
  28.         time.sleep(5) 
  29.         print('第{}页抓取完毕'.format(i+1)) 
  30.         for item in get_dates(selector): 
  31.             print(item) 
  32.         with open('Py.csv', 'a', newline='') as csvfile:  ##Py.csv是文件的生涯路径,这里默认生涯在事变目次 
  33.             fieldnames = ['Name', 'Company', 'Salary', 'Education', 'Size', 'Welfare'] 
  34.             writer = csv.DictWriter(csvfile, fieldnames=fieldnames) 
  35.             writer.writeheader() 
  36.             for item in get_dates(selector): 
  37.                 writer.writerow(item) 
  38.         time.sleep(5) 
  39.     browser.close() 
  40. if __name__=='__main__': 
  41.     main() 

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读