20 Aug
scRUBYt!: uno strumento potente per il web scraping in Ruby
scRUBYt! estrae contenuto dal Web e lo restituisce in XML. Nell’articolo Scrapin’ Google in no sec c’è un possibile scenario di utilizzo, l’idea è quella di fare una ricerca su google ed estrarre i risultati cercando gli a href ciclando sulle prime due pagine di risultati; questo è l’estratto del codice:
1 2 3 google_data = Scrubyt::Extractor.define do 4 #Perform the action(s) 5 fetch ‘http://www.google.com/ncr’ 6 fill_textfield ‘q’, ‘ruby’ 7 submit 8 #Construct the wrapper 9 link "Ruby Programming Language" do 10 url "href", :type => :attribute 11 end 12 next_page "Next", :limit => 2 13 end 14 puts google_data.to_xml
e su pastie.caboo.se potete vedere il risultato; gli scenari di utilizzo sono molti e tutti molto interessanti, lo proverò!


Salve a tutti ho un problema, scrivendo questo codice:
—————————————*
require ‘rubygems’
require ’scrubyt’
test_data = Scrubyt::Extractor.define do
fetch(’https://metalink.oracle.com/metalink/plsql/f?p=130:10:1786236168764095279::::alltext,knowledge,archive,bug,forums,numHits:java,TRUE,TRUE,TRUE,TRUE,100′, :proxy => “proxy:3128″)
primoTxt=”pt02″
secondoTxt=”pt03″
filltextfield primoTxt.tos, ‘xxxxxxxx’
filltextfield secondoTxt.tos, ‘xxxxxxxx’
submit
end
puts testdata.toxml
————————————–*
ruby mi produce questo codice:
———————————————*
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/navigation/navigationactions.rb:97:in findformbasedontag’: undefined methodattributes’ for # (NoMethodError)
from c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/navigation/navigationactions.rb:95:in each’
from c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/navigation/navigationactions.rb:95:infindformbasedontag’
from c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/navigation/navigationactions.rb:88:in lookupformfortag’
from c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/navigation/navigationactions.rb:34:infilltextfield’
from c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/extractor.rb:92:in send’
from c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/extractor.rb:92:inmethodmissing’
from C:/TEMP2/rb4059.tmp:11
from c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/extractor.rb:31:in classeval’
from c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/extractor.rb:31:indefine’
from C:/TEMP2/rb4059.tmp:4
[MODE] Learning
[ACTION] Setting proxy: host=, port=<3128>
[ACTION] fetching document: https://metalink.oracle.com/metalink/plsql/f?p=130:10:1786236168764095279::::alltext,knowledge,archive,bug,forums,numHits:java,TRUE,TRUE,TRUE,TRUE,100
[ACTION] typing xxxxxxxxx into the textfield named ‘pt_02′
Complete(1)
————————————-*
Da ciò che pare a me sembra che non trovi il textfield in cui inserire i parametri, ma io o controllato e ricontrollato ed il nome e proprio quello.
Come posso fare?
Grazie in anticipo dell’aiuto
Accedendo al link che mi hai mandato
i due input che ci sono si chiamano hanno come “name” quelli che hai scritto nel post e come id “P101PASSWORD” e “P101USERNAME”, prova a mettere l’id anziché il name!
Avevi provato a mettere l’id?
Ti ringrazio per la risposta, comunque avevo provato a mettere anche gli id, non solo ho provato anche altri metodi ma niente, è come se non trovasse i text_field dove inserire il testo, eppure con altri siti funziona tipo yahoo o youtube, ma questo non ne vuole proprio sapere come devo fare non ne ho più idea HELP!
Ciao