Last active
August 29, 2015 14:06
-
-
Save rochefort/828fa2d1fc1e48fbe4ce to your computer and use it in GitHub Desktop.
2-6-3 scraping_with_cookie.rb (p.108)
This file contains hidden or 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
diff --git a/chapter2/scraping-with-cookie.rb b/chapter2/scraping-with-cookie.rb | |
index 7d5b289..d3d07cd 100644 | |
--- a/chapter2/scraping-with-cookie.rb | |
+++ b/chapter2/scraping-with-cookie.rb | |
@@ -24,8 +24,10 @@ opts = { | |
Anemone.crawl(urls, opts) do |anemone| | |
anemone.on_every_page do |page| | |
doc = Nokogiri::HTML.parse(page.body.toutf8) | |
- communityList.each {|community| | |
+ community_list = doc.xpath("//*[@id='communityList']/div[2]/table/tr/td")^M | |
+ community_list.each {|community|^M | |
puts community.content | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
community_listのpath抽出が抜けています。
蛇足ですが、snake_case 使いましょうってのとrubyistはsoft tab使う方が非常に多いです。