美文网首页技术干货Coding关于搜索,我们聊聊
爬虫抓取ruby-china职位分布图,含代码

爬虫抓取ruby-china职位分布图,含代码

作者: AQ王浩 | 来源:发表于2014-11-04 22:12 被阅读1424次

Jobs数量地区分布图

    #   +------+-----------+
    #   | area | Job数量   |
    #   +------+-----------+
    #   |    1 |       424 |  北京
    #   |    2 |       291 |  上海
    #   |    3 |        73 |  广州
    #   |    4 |        46 |  深圳
    #   |    5 |        62 |  杭州
    #   |    6 |        45 |  成都
    #   |    7 |        39 |  remote
    #   |    8 |       127 |  others
    #   +------+-----------+

点赞最多的 Topic

https://ruby-china.org//topics/13680

给薄荷网赞一个!

下面是主要程序片段

    desc "获取ruby-china.org上的工作"
    task :get_jobs => :environment do
      time_start     = Time.now
      Job.connection
      (1..74).each do |_id|
        url = "https://ruby-china.org/jobs?page=#{_id}"
        doc = Nokogiri::HTML(open(url))
        doc.xpath("//div[@class='topics']/div").each do |_line|
          topic_class     = _line['class']
          right_info_path = "//div[@class='#{topic_class}']/div[@class='right-info']"
          topic_path      = right_info_path +"/div[@class='pull-right replies']/a"
          # 获取点赞数量
          up =  doc.xpath(topic_path).text
          up =  0 if up.empty?
  
          # 获取标题
          title_path      = right_info_path + "/div[@class='infos']/div[@class='title']/a"
          title           = doc.xpath(title_path)[0]['title']
  
          # 获取url
          url_suffix      = doc.xpath(title_path)[0]['href']
          url             = "https://ruby-china.org/#{url_suffix}"
          area            = cal_area(title)
          job             = Job.create!(title: title, area: area, up: up, url: url)
  
          puts "#{title}"
        end
      end
  
      time_end   = Time.now
      puts "rake 执行完毕!耗时#{ time_end - time_start }秒"
    end
  

Top 20

 mysql> select title, up, url from jobs order by up desc limit 20\G;
 *************************** 1. row ***************************
 title: [上海]薄荷科技寻找靠谱的 Rubyist
    up: 125
   url: https://ruby-china.org//topics/13680
 *************************** 2. row ***************************
 title: [广州] 招聘 Ruby 程序员【已结束】
    up: 124
   url: https://ruby-china.org//topics/14975
 *************************** 3. row ***************************
 title: [西安] 途途科技招聘 Ruby/Rails 工程师 / 实习生
    up: 111
   url: https://ruby-china.org//topics/18818
 *************************** 4. row ***************************
 title: [北京] 酷传招聘Ruby on Rails全职实习生/初级工程师,当然我们也喜欢高手
    up: 106
   url: https://ruby-china.org//topics/5112
 *************************** 5. row ***************************
 title: [上海][浦东][扩招]一名 Ruby 工程师(附靓照)【已结束】
    up: 102
   url: https://ruby-china.org//topics/12391
 *************************** 6. row ***************************
 title: [北京] 天际网寻觅初、中、高级 Rubyist [暂停招聘]
    up: 95
   url: https://ruby-china.org//topics/5745
 *************************** 7. row ***************************
 title: [南京]暴走漫画招聘 rails 程序员(内有无节操图,慎入)
    up: 94
   url: https://ruby-china.org//topics/12431
 *************************** 8. row ***************************
 title: [日本] 宣传下我现在就职的公司:日本COOKPAD
    up: 90
   url: https://ruby-china.org//topics/864
 *************************** 9. row ***************************
 title: [深圳] Knewone.com 招聘 Ruby/Javascript/iOS 程序员
    up: 90
   url: https://ruby-china.org//topics/11561
 *************************** 10. row ***************************
 title: [北京][上海][远程] Doorder 招聘 Ruby on Rails 高级开发工程师
    up: 89
   url: https://ruby-china.org//topics/19290
 *************************** 11. row ***************************
 title: [上海] 百度诚招高级研发工程师 Ruby
    up: 89
   url: https://ruby-china.org//topics/15393
 *************************** 12. row ***************************
 title: [北京] 招靠谱 Ruby 攻城狮
    up: 83
   url: https://ruby-china.org//topics/3867
 *************************** 13. row ***************************
 title: [上海] "英语流利说"诚聘 Rails 开发工程师
    up: 80
   url: https://ruby-china.org//topics/12746
 *************************** 14. row ***************************
 title: 此贴复活![杭州] 急招 Ruby 工程师,前端工程师,iOS,安卓,产品经理,月薪 10k-25k,办公地点可以自选.
    up: 77
   url: https://ruby-china.org//topics/15650
 *************************** 15. row ***************************
 title: [已结束][上海] 掌誉网络科技招聘靠谱Ruby程序员 - 你看了以后可能几天都睡不好觉的招聘帖
    up: 76
   url: https://ruby-china.org//topics/8893
 *************************** 16. row ***************************
 title: [深圳] KnewOne 招聘开发实习生(北京也招聘前后端开发)
    up: 75
   url: https://ruby-china.org//topics/17881
 *************************** 17. row ***************************
 title: [欧洲] Chinese speaker Ruby/JS/Web Developer - 招聘已结束
    up: 75
   url: https://ruby-china.org//topics/12750
 *************************** 18. row ***************************
 title: [杭州] The Plant 招人
    up: 71
   url: https://ruby-china.org//topics/2391
 *************************** 19. row ***************************
 title: [杭州滨江] 急招 Ruby 大神?高手?长者?
    up: 68
   url: https://ruby-china.org//topics/17351
 *************************** 20. row ***************************
 title: [广州] 招聘 Ruby / Rails 程序员
    up: 67
   url: https://ruby-china.org//topics/4337
 20 rows in set (0.00 sec)

附加:PM2.5 对比

北京 vs 上海

北京 vs 广州

北京 vs 杭州

北京 vs 深圳

个人爱好,不喜勿喷。

宣传语

历经两个半月的准备,三次大改版,十七次小改版。le1024终于要和大家见面了。

le1024每天推荐1~3段,有趣、有爱、有故事的视频。

为您工作、学习、生活之余增加一点快乐的感觉。

相关文章

  • 爬虫抓取ruby-china职位分布图,含代码

    Jobs数量地区分布图 点赞最多的 Topic 给薄荷网赞一个! 下面是主要程序片段 Top 20 附加:PM2....

  • 基于Python的豆瓣影评分析——数据预处理

    一、数据抓取 利用python软件,抓取豆瓣网上关于《向往的生活》的影视短评,进行网页爬虫,爬虫代码如下: ...

  • 学习网址

    Python开源爬虫项目代码:抓取淘宝、京东、QQ、知网数据 scrapy_jingdong[9]- 京东爬虫。基...

  • python爬虫-36kr网+Django+Echarts图表

    一.爬虫作业:抓取36kr网站数据 爬虫代码和数据sql脚本在下方链接,抓取过程主要是抓包找到url递归解析的规律...

  • python猫眼电影爬虫+Django+Echarts图表

    一.爬虫作业:抓取猫眼电影网站数据 二.Django+echarts图表 三.爬虫和django代码 猫眼爬虫gi...

  • python3.6之抓取LaGou网爬虫职位详解

    目标:抓取LaGou网爬虫职位,下载于数据库MongoDB,并可视化于pycharm。 我们采用:requests...

  • spider(爬虫)

    spider(爬虫) 推荐抓取工具:火车采集器\火车头采集器 爬虫抓取网页 jsdom.js 爬虫抓取数据

  • 25.使用pyspider爬取阿里招聘

    阿里招聘爬虫 对于这样一个网页 我想要抓取它的职位信息,只有前面这些肯定远远不够,想要抓取它的详情页,这个样式滴 ...

  • Python项目收录

    爬虫类 crawlers是一个主要抓取ROSI写真的Scrapy爬虫,主要的spider代码简单易理解。 163s...

  • 网络爬虫(一)

    网络爬虫是一种程序,通过代码运行模拟浏览器上网,去网站(网页)上抓取数据。 爬虫大约分三种: 通用爬虫: 获取相关...

网友评论

  • rico93:漂亮的图表 怎么生成的
  • AQ王浩:只需要实现下 ` cal_area(title)` 方法就可以了,并不是很复杂的。

    def cal_area(title)
    if title.present?
    return 1 if title.include?("北京")
    return 2 if title.include?("上海")
    return 3 if title.include?("广州")
    return 4 if title.include?("深圳")
    return 5 if title.include?("杭州")
    return 6 if title.include?("成都")
    return 7 if title.include?("remote") || title.include?("远程") || title.include?("Remote")
    end
    return 8
    end
  • _z3ro:挺好玩的一个应用,之前学过ruby,但没怎么写过东西,懒人一个,喜欢收藏可执行的代码,虽然已给出了主要代码片段,但还是想问问,有完整的代码么?`(*∩_∩*)′

本文标题:爬虫抓取ruby-china职位分布图,含代码

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