Created
November 24, 2011 00:31
-
-
Save tobynet/1390341 to your computer and use it in GitHub Desktop.
ループものの作品名を列挙するやつ for scraperwiki https://scraperwiki.com/scrapers/time-loop-story-lang_ja/
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
| # -*- encoding: utf-8 -*- | |
| %w|rubygems mechanize open-uri|.each{|x| require x} | |
| target = "http://ja.wikipedia.org/wiki/%E3%83%AB%E3%83%BC%E3%83%97%E3%82%82%E3%81%AE" | |
| # scrape | |
| doc = Mechanize.new{|a|a.user_agent_alias = "Windows Mozilla"}.get(target) | |
| # get stories only | |
| stories = doc.search('#bodyContent .mw-content-ltr').text.scan(/『(.+?)』/).map(&:first).uniq | |
| # save to DB | |
| ScraperWiki.save_sqlite(unique_keys=[:name], stories.map{|x| {:name => x} }) | |
| puts stories |
Author
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
scraperwikiってgistやgithubと連携できないのかな