Created
April 16, 2016 02:27
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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