Skip to content

Instantly share code, notes, and snippets.

@everaldo
Created April 16, 2016 02:27
Show Gist options
  • Select an option

  • Save everaldo/a76a1247d663ed336daa1e07fd5ccdcc to your computer and use it in GitHub Desktop.

Select an option

Save everaldo/a76a1247d663ed336daa1e07fd5ccdcc to your computer and use it in GitHub Desktop.
Based On Thiago Harry's Bulbapedia Bot - Work In Progress - Original URL: http://pastebin.com/1vANKnUf
require 'nokogiri'
require 'open-uri'
BULBAPEDIA_URL='http://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_National_Pok%C3%A9dex_number'
doc = Nokogiri::HTML(open(BULBAPEDIA_URL))
Pokemon = Struct.new(:name, :url, :img)
pokemons = doc.css("img[width='40']").map do |element|
element.parent
end.map do |link|
name = link['title']
url = link['href']
img = link.css('img').first['src']
Pokemon.new(name, url, img)
end
puts pokemons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment