Nestor

Mon petit bot Discord
Log | Files | Refs

commit aca122486b1230df4d4e3a92d59db2687b27e9d7
parent aa5d180c220c042c066d99d369e55545002093b0
Author: Doshirae <romainchaix@protonmail.com>
Date:   Sun, 25 Dec 2016 15:45:08 +0100

First commit

Diffstat:
poke.rb | 35+++++++++++++++++++++++++++++++++++
strawpoll.rb | 8++++++++
2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/poke.rb b/poke.rb @@ -0,0 +1,35 @@ +require 'nokogiri' +require 'open-uri' +# [Pokemon] +# [evo1 --[moyen d'obtention]-> evo 2 ---> mega evo +# [types] [talents] + +# [pv] +# [atk] +# [defense] +# [SpAtk] +# [SpDef] +# [Spd] + +# [Resistances/faiblesses]] + +page = Nokogiri::HTML(open('BulbizarreEntier.html')) +# name = Bulbizarre +# évolutions +evo1 = page.css("table > tr:has(th:contains('évolution')) + tr td").text +moyen_evo1 = page.css("table tr:has(th:contains('évolution')) + tr + tr td").text.split('').grep(/[A-Za-z0-9 ]+/).join +evo2 = page.css("table > tr:has(th:contains('évolution')) + tr + tr + tr td").text +moyen_evo2 = page.css("table tr:has(th:contains('évolution')) + tr + tr + tr + tr td").text.split('').grep(/[A-Za-z0-9 ]+/).join +evo3 = page.css("table > tr:has(th:contains('évolution')) + tr + tr + tr + tr + tr td").text + +# types : +typesHTML = page.css('table tr th:contains("Types") + td a') # just got to figure out how to extract the title +types = typesHTML.filter("title") + +# talents : +talents = page.css("table tr th:contains('Talents') + td a").text.split(/(?=[A-Z])/) +talents[-2] += " (#{talents[-1]})" +talents.pop + +# Stats +# pv, atk, def, spAtk, spDef, vitesse diff --git a/strawpoll.rb b/strawpoll.rb @@ -0,0 +1,8 @@ +require 'mechanize' +mechanize = Mechanize.new +page = mechanize.get('http://www.strawpoll.me/') +form = page.forms[1] + +form.fields.each do |f| + puts f.name +end