Advertisement
sinulucky

new one

Feb 6th, 2017
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.80 KB | None | 0 0
  1. require 'nokogiri'
  2. require 'open-uri'
  3.  
  4.  
  5. urltext = 'http://oploverz.in/page/%d/'
  6.  
  7. links = []
  8. (1..3).each do |i|
  9.     page = Nokogiri::HTML(open(urltext % i))
  10.     page.css('.dtl h2 a[href]').each do |line|
  11.         links << line.attr(:href)
  12.     end
  13. end
  14.  
  15. links.each do |link|
  16.  
  17.         post = Nokogiri::HTML(open(urltext))
  18.         name = post.css(".dtl h1")
  19.         sinops = post.css(".sinop p")
  20.         oplink = post.css("soraddl.op-download")[0]
  21.         opdl = oplink.css(".soraurl.list-download")[0..1]
  22.         small = opdl.css("span strong a[href]")[0..3].attr(:href)
  23.         medium = opdl.css("span strong a[href]")[4..7].attr(:href)
  24.  
  25.         posts << {
  26.             name: name,
  27.             sinops: sinops,
  28.             small: small,
  29.             medium: medium
  30.         }
  31.     end
  32.  
  33.  
  34. puts posts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement