Created
December 11, 2013 13:45
-
-
Save gouf/7910670 to your computer and use it in GitHub Desktop.
2015年 就職情報サイトから、企業名で検索して紹介ページURL を取得する。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mechanize' | |
m = Mechanize.new {|agent| | |
agent.user_agent_alias = 'Mac Safari' | |
} | |
URL = 'http://job.rikunabi.com/2015/s/?freeword=' | |
companies = %w(ハル研究所 任天堂 三菱 トヨタ) | |
companies.each do |param| | |
page = m.get(URL + param) | |
regex = /2015\/company\/top\/.*\// | |
uri = page.links_with(href: regex).first.uri.to_s # get first search result | |
prefix = 'http://job.rikunabi.com' | |
puts prefix + uri | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'watir-webdriver' | |
file_path = 'where-to-save-file.txt' | |
f = File.new(file_path, 'w') | |
companies = %w(ハル研究所 任天堂 三菱 トヨタ) | |
b = Watir::Browser.new | |
companies.each do |query| | |
b.goto 'http://job.mynavi.jp/15/pc/toppage/displayTopPage/index' | |
b.text_field(name: 'srchWordCorp').set query | |
b.button(name: 'doSearchCorpName').click | |
f.puts b.h3s.first.a.href # saving first search result | |
end | |
b.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment