Created
December 23, 2014 15:51
-
-
Save shirayuca/4d26a5abb52a0ef0aeff to your computer and use it in GitHub Desktop.
vorkers_detail_repeat.rb
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
http://www.vorkers.com/company.php?m_id=a0910000000Fr7P | |
http://www.vorkers.com/company.php?m_id=a0910000000Fr6b | |
http://www.vorkers.com/company.php?m_id=a0910000000Frvw |
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 'open-uri' | |
require 'nokogiri' | |
def getList(company_url) | |
charset = nil | |
html = open(company_url) do |f| | |
charset = f.charset | |
f.read | |
end | |
doc = Nokogiri::HTML.parse(html, nil, charset) | |
doc.xpath('//ul/li[@class="r1"]').each do |node| | |
print node.text + "," | |
end | |
doc.xpath('//ul/li[@class="r2"]').each do |node| | |
print node.text + "," | |
end | |
doc.xpath('//ul/li[@class="r1_2"]/span[@class="suchiup"]').each do |node| | |
print node.text + "," | |
end | |
print "\n" | |
end | |
open('companylist.txt').each do |line| | |
print line.chomp! + "," | |
getList(line) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment