Skip to content

Instantly share code, notes, and snippets.

@irvin373
Created June 21, 2017 02:58
Show Gist options
  • Save irvin373/01044b8d9e020222f215147c7d85b203 to your computer and use it in GitHub Desktop.
Save irvin373/01044b8d9e020222f215147c7d85b203 to your computer and use it in GitHub Desktop.
is a ruby scrapper for page https://wall.alphacoders.com downloader images
require 'cocaine'
require 'open-uri'
require 'nokogiri'
$iterator = 0
def getName(link)
$iterator+=1
link.to_s.split('/').last + "#{$iterator}.png"
end
def download(url)
doc = Nokogiri::HTML(open(url))
links = doc.css('.btn btn-primary', '.download-button')
links = links.map{|button| button.attr('data-href')}
comands = links.map {|link| Cocaine::CommandLine.new("curl", "-o #{getName(link)} #{link}")}
comands.each{|comand| comand.run}
end
url = 'https://wall.alphacoders.com/search.php?search=raichu'
download(url)
#for i in 2..8
# url = "https://wall.alphacoders.com/tags.php?tid=142&page=#{i}"
# puts url
# download(url)
#end
# comands = links.map {|link| Cocaine::CommandLine.new("wget"," #{link}")}
@irvin373
Copy link
Author

In line 20 is for pages result indexer and url in line 18 is the url of search replace for download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment