Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'nokogiri'
- require 'open-uri'
- require 'byebug'
- url = 'http://oploverz.in/page/%d'
- links = []
- (1..3).each do |i|
- page = Nokogiri::HTML(open(url % i))
- page.css('.dtl h2 a[href]').each do |line|
- links << line.attr(:href)
- end
- end
- oploverzs = []
- links.each do |link|
- page = Nokogiri::HTML(open(links))
- name = page.css(".dtl h1").text.strip
- sinops = page.css(".sinop p").text.strip
- smalls = []
- mediums = []
- link_1 = page.css("soraddl.op-download")[0]
- lista = link_1.css(".soraurl.list-download")[0]
- listb = lista.css("span strong a[href]")[0..3].each do |small|
- smalls << small.attr(:href).strip.split
- end
- link_2 = page.css("soraddl.op-download")[0]
- listc = link_2.css(".soraurl.list-download")[1]
- listd = listc.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 }
- end
- oploverzs.each do |oploverz|
- @post = Post.new
- @post.title = oploverz[:title]
- @post.sinops = oploverz[:sinops]
- @post.small = oploverz[:small].join(",")
- @post.medium = oploverz[:medium].join(",")
- @post.save
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement