Skip to content

Instantly share code, notes, and snippets.

@iurikura

iurikura/sample7.rb

Last active Jan 9, 2017
Embed
What would you like to do?
# sample5.rb をベースに Clips を取り出します。Clips は /username/ディレクトリ配下にあるため、観た映画より取り出しやすいです。
require 'nokogiri'
require 'anemone'
opts = {
depth_limit: 2
}
URL = "https://filmarks.com/users/hogehoge" # hogehoge に Username を入れてください
Anemone.crawl(URL, opts) do |anemone|
anemone.focus_crawl do |page|
page.links.keep_if { |link|
link.to_s.match(/clips/)  
}
end
anemone.on_every_page do |page|
doc = Nokogiri::HTML.parse(page.body)
clipscores = doc.xpath('//html/body/div[3]/div[3]/div[1]/div/h3/a/text()|//html/body/div[3]/div[3]/div[1]/div/div/div[3]/a/span/text()')
clipscores.each do |titlescore|
p clipscore.text
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment