Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'nokogiri'
- require 'open-uri'
- # require 'byebug'
- urltext = 'http://oploverz.in/page/%d'
- links = []
- (1..3).each do |i|
- page = Nokogiri::HTML(open(urltext % i))
- page.css('.thumbnail a[href]').each do |line|
- links << line.attr(:href)
- end
- end
- # links = []
- # (1..3).each do |i|
- # page = Nokogiri::HTML(open(urltext % i))
- # page.css('.dtl h2 a[href]').each do |line|
- # links << line.attr(:href)
- # end
- # end
- oploverzs = []
- smalls = []
- mediums = []
- links.each do |link|
- page = Nokogiri::HTML(open(link))
- name = page.css(".featured2 h1").text.strip
- sinops = page.css(".sinop p").text.strip
- # anime_info = page.css(".animeinfo")
- # info_a = anime_info.css(".left")
- # img = info_a.css("img").attr('src')[1]
- link1 = page.css(".soraddl.op-download")[0]
- lista = link1.css(".soraurl.list-download")[0]
- listb = lista.css("span strong a[href]")[0..3].each do |small|
- smalls << small.attr(:href).strip.split(/ | /)
- end
- link2 = page.css(".soraddl.op-download")[0]
- linkc = link2.css(".soraurl.list-download")[1]
- linkd = linkc.css("span strong a[href]")[0..3].each do |medium|
- mediums << medium.attr(:href).strip.split(',')
- end
- oploverzs << {
- title: name,
- sinops: sinops,
- # small: smalls,
- # medium: mediums
- }
- # images << {
- # url: img
- # }
- # end
- oploverzs.each do |oploverz|
- @title = Title.new
- @title.title = oploverz[:title]
- @title.sinops = oploverz[:sinops]
- # @title.small = oploverz[:small].join(" | ")
- # @title.medium = oploverz[:medium].join(" | ")
- @title.save
- # images.each do |image|
- # @image = Image.new
- # @image.url = image[:url]
- # @image.post_id = @post.id
- # @image.save
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement