lib/nokaya/getter.rb in nokaya-0.0.5 vs lib/nokaya/getter.rb in nokaya-0.0.6
- old
+ new
@@ -14,17 +14,10 @@
@args.type
end
def url
@args.url
end
- def get_image img_link
- begin
- open(img_link).read
- rescue
- abort Status.no_can_do
- end
- end
def get_basic page
page.xpath("//meta[@property='og:image']/@content").first
end
def get_favd page
page.css('#largeImage')[0]['src']
@@ -33,20 +26,32 @@
refs = page.css('#imagelist .posts .post a')
links = []
refs.each {|l| links << "http:#{l['href']}"}
links
end
+ def get_tumblr_album page
+ queries = ['img.photo', '.post .photo a img', '.entry img', 'article img', '.image img', '.item_content img', 'img.post-image', '.box img', '#allposts img', '.media img', '.wide img', '.big img', '.large img', '.gallery img', '.photos img', 'img']
+ queries.each do |query|
+ @refs = page.css query
+ next if @refs.empty?
+ break
+ end
+ links = []
+ @refs.each do |l|
+ target = l['src']
+ unless (target == 'reblog.png' || target =~ /statcounter/ || target =~ /impixu/ || target =~ /quantserve/ || target == 'like.png')
+ links << target
+ end
+ end
+ links
+ end
def get_flickr_album page
refs = page.css('.pc_img')
links = []
refs.each {|l| links << l['data-defer-src']}
links
end
def parse_page
- Nokogiri::HTML get_page_content
- end
- private
- def get_page_content
- open @args.url
+ Nokogiri::HTML(open @args.url)
end
end
end