Ross Cameron
2009-Dec-15 06:09 UTC
[Mechanize-users] Missing form in the #<WWW::Mechanize::Form ... list
Trying to use BabelFish (http://babelfish.yahoo.com/) to do a translation of text via Mechanize. Their are a couple of forms on it, the form in question being "frmTrText". It all looked pretty straight forward to me, but then again, sometimes ... Anyway, examining page.body, the form is there, as are the other forms, but it doesn''t appear in the #<WWW::Mechanize::Form ... list. Code I am using is: agent = WWW::Mechanize.new page = agent.get(http://babelfish.yahoo.com/translate_txt) sf = page.form(''frmTrText'') pp sf => nil Would appreciate any thoughts on what could be the issue or some direction to resolving the problem. Regards Ross -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/mechanize-users/attachments/20091215/ce0547bc/attachment.html>
jeremywoertink at gmail.com
2009-Dec-15 08:12 UTC
[Mechanize-users] Missing form in the #<WWW::Mechanize::Form ... list
A couple questions... 1. What version of mechanize are you using? 2. Is the form generated by javascript? 3. Have you tried other methods like page.forms.length To see how many come up? If that comes up as 0, Then examine then page object. Hope that helps ~jeremy woertink On Dec 14, 2009, at 10:09 PM, Ross Cameron <ross at roscommonhq.com> wrote:> Trying to use BabelFish (http://babelfish.yahoo.com/) to do a > translation of text via Mechanize. > > Their are a couple of forms on it, the form in question being > "frmTrText". > > It all looked pretty straight forward to me, but then again, > sometimes ... > > Anyway, examining page.body, the form is there, as are the other > forms, but it doesn''t appear in the #<WWW::Mechanize::Form ... list. > > Code I am using is: > agent = WWW::Mechanize.new > page = agent.get(http://babelfish.yahoo.com/translate_txt) > sf = page.form(''frmTrText'') > > pp sf > > => nil > > Would appreciate any thoughts on what could be the issue or some > direction to resolving the problem. > > Regards > Ross > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/mechanize-users/attachments/20091215/227085eb/attachment.html>
Ross Cameron
2009-Dec-15 09:39 UTC
[Mechanize-users] Missing form in the #<WWW::Mechanize::Form ... list
All good questions. Thanks. Mechanize version 0.9.3 Hpricot version 0.8.2 No, javascript isn''t involved, it is a static page. paged.forms.length = 2 when in fact there are 3 on the page which also show in page.body. So I have tried it with nokogiri (1.4.0) and it works. Looks like an Hpricot issue. Many thanks for getting me thinking. Ross ------------------------------------------------------------------------ Ross Cameron | Director Roscommon Pty Ltd | ABN 85 099 499 840 p: +61 2 9016 4133 <callto:+61%202%209016%204133> | m: +61 4 3312 9087 <callto:+61%204%203312%209087> | f: +61 2 9420 4525 <callto:+61%202%209420%204525> | w: www.roscommonhq.com <http://www.roscommonhq.com> | AIM: rossppc Roscommon uses the five sentences <http://five.sentenc.es> email reply policy. Please consider our environment before printing this email. NOTE: This email and any attachments may be confidential. If received in error, please delete the email. Because emails and attachments may be interfered with, may contain computer viruses or other defects and may not be successfully replicated on other systems, you must be cautious. Roscommon cannot guarantee that what you receive is what we sent. If you have any doubts about the authenticity of an email from Roscommon, please contact us immediately. jeremywoertink at gmail.com wrote:> A couple questions... > > 1. What version of mechanize are you using? > 2. Is the form generated by javascript? > 3. Have you tried other methods like > > page.forms.length > > To see how many come up? If that comes up as 0, > Then examine then page object. > > > Hope that helps > ~jeremy woertink > > > > On Dec 14, 2009, at 10:09 PM, Ross Cameron <ross at roscommonhq.com > <mailto:ross at roscommonhq.com>> wrote: > >> Trying to use BabelFish (http://babelfish.yahoo.com/) to do a >> translation of text via Mechanize. >> >> Their are a couple of forms on it, the form in question being >> "frmTrText". >> >> It all looked pretty straight forward to me, but then again, >> sometimes ... >> >> Anyway, examining page.body, the form is there, as are the other >> forms, but it doesn''t appear in the #<WWW::Mechanize::Form ... list. >> >> Code I am using is: >> agent = WWW::Mechanize.new >> page = agent.get(http://babelfish.yahoo.com/translate_txt) >> sf = page.form(''frmTrText'') >> >> pp sf >> >> => nil >> >> Would appreciate any thoughts on what could be the issue or some direction to resolving the problem. >> >> Regards >> Ross >> >> _______________________________________________ >> Mechanize-users mailing list >> Mechanize-users at rubyforge.org <mailto:Mechanize-users at rubyforge.org> >> http://rubyforge.org/mailman/listinfo/mechanize-users > ------------------------------------------------------------------------ > > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/mechanize-users/attachments/20091215/729fa782/attachment-0001.html>
jeremywoertink at gmail.com
2009-Dec-15 15:41 UTC
[Mechanize-users] Missing form in the #<WWW::Mechanize::Form ... list
Glad you figured it out. Sometimes it just helps to talk it out. I was gonna ask why you were using hpricot. LOL. ~jeremy woertink On Dec 15, 2009, at 1:39 AM, Ross Cameron <ross at roscommonhq.com> wrote:> All good questions. Thanks. > > Mechanize version 0.9.3 > Hpricot version 0.8.2 > > No, javascript isn''t involved, it is a static page. > > paged.forms.length = 2 when in fact there are 3 on the page which > also show in page.body. > > So I have tried it with nokogiri (1.4.0) and it works. Looks like an > Hpricot issue. > > Many thanks for getting me thinking. > > Ross > > > Ross Cameron | Director > Roscommon Pty Ltd | ABN 85 099 499 840 > p: +61 2 9016 4133 | m: +61 4 3312 9087 | f: +61 2 9420 4525 | w: www.roscommonhq.com > | AIM: rossppc > > Roscommon uses the five sentences email reply policy. Please > consider our environment before printing this email. > > NOTE: This email and any attachments may be confidential. If > received in error, please delete the email. Because emails and > attachments may be interfered with, may contain computer viruses or > other defects and may not be successfully replicated on other > systems, you must be cautious. Roscommon cannot guarantee that what > you receive is what we sent. If you have any doubts about the > authenticity of an email from Roscommon, please contact us > immediately. > > > jeremywoertink at gmail.com wrote: >> >> A couple questions... >> >> 1. What version of mechanize are you using? >> 2. Is the form generated by javascript? >> 3. Have you tried other methods like >> >> page.forms.length >> >> To see how many come up? If that comes up as 0, >> Then examine then page object. >> >> >> Hope that helps >> ~jeremy woertink >> >> >> >> On Dec 14, 2009, at 10:09 PM, Ross Cameron <ross at roscommonhq.com> >> wrote: >> >>> Trying to use BabelFish (http://babelfish.yahoo.com/) to do a >>> translation of text via Mechanize. >>> >>> Their are a couple of forms on it, the form in question being >>> "frmTrText". >>> >>> It all looked pretty straight forward to me, but then again, >>> sometimes ... >>> >>> Anyway, examining page.body, the form is there, as are the other >>> forms, but it doesn''t appear in the #<WWW::Mechanize::Form ... list. >>> >>> Code I am using is: >>> agent = WWW::Mechanize.new >>> page = agent.get(http://babelfish.yahoo.com/translate_txt) >>> sf = page.form(''frmTrText'') >>> >>> pp sf >>> >>> => nil >>> >>> Would appreciate any thoughts on what could be the issue or some >>> direction to resolving the problem. >>> >>> Regards >>> Ross >>> >> >>> _______________________________________________ >>> Mechanize-users mailing list >>> Mechanize-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/mechanize-users >> >> _______________________________________________ >> Mechanize-users mailing list >> Mechanize-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/mechanize-users > > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/mechanize-users/attachments/20091215/c5b57b55/attachment.html>