Skip to content

Instantly share code, notes, and snippets.

@rochefort
Last active August 29, 2015 14:06
Show Gist options
  • Save rochefort/828fa2d1fc1e48fbe4ce to your computer and use it in GitHub Desktop.
Save rochefort/828fa2d1fc1e48fbe4ce to your computer and use it in GitHub Desktop.
2-6-3 scraping_with_cookie.rb (p.108)
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
@rochefort
Copy link
Author

community_listのpath抽出が抜けています。
蛇足ですが、snake_case 使いましょうってのとrubyistはsoft tab使う方が非常に多いです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment