Re: [wtr-general] Re: How to get html meta details
This is a really old post! I'm guessing at the time there wasn't an easier way of doing this, but now you can do something like the below. b.metas.each do |m| puts m.name puts m.title end On Tuesday, March 19, 2013 3:22:30 AM UTC-4, Soori wrote: > > > Hi Marlon, > > I tried the above code and I am getting the following error, > > Ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:48: > > stack level too deep (SystemStackError) > > Watir version: Watir4. > > Please advise what am I doing wrong here. > > Thanks, > S > On Wednesday, 4 November 2009 12:40:40 UTC+5:30, Marlon wrote: >> >> yes for now this is the best solution I have. >> >> On 11/4/09, Wesley Chen wrote: >> > Thank you very much. >> > Only this way to get the meta data? I think it is not convenient >> enough. >> > >> > Thanks. >> > Wesley Chen. >> > For life, the easier, the better. >> > >> > >> > On Tue, Nov 3, 2009 at 10:41 PM, chandu.tennety >> > wrote: >> > >> >> >> >> Marlon, >> >> Your original code works for me: >> >> >> >> {"Content-Type"=>"text/html; charset=iso-8859-1", "keywords"=>"title"} >> >> >> >> Chandu >> >> >> >> On Nov 2, 10:51 pm, Marlon wrote: >> >> > I found the part of the solution herehttp:// >> >> groups.google.com/group/watir-general/browse_thread/thread/566... >> >> > it still did not solve my problem. >> >> > >> >> > *sample html* >> >> > >> >> > >> >> > >> >> > title >> >> > >> >> > > >> > http-equiv="Content-Type"/> >> >> > >> >> > *ruby file* >> >> > >> >> > require 'watir' >> >> > require 'test/unit' >> >> > >> >> > class TC_MyTest < Test::Unit::TestCase >> >> > >> >> > def test_meta_get >> >> > $ie = Watir::IE.start('') >> >> > d=meta($ie) >> >> > puts d >> >> > end >> >> > >> >> > def meta( browser ) >> >> > meta = {} >> >> > bmeta = >> >> > browser.document.body.parentElement.getElementsByTagName( "META" ) >> >> > bmeta.each do |i| >> >> > k = i.name >> >> > if k == "" >> >> > k = i.httpEquiv >> >> > end >> >> > meta[ k ] = i.content >> >> > end >> >> > return meta >> >> > end >> >> > end >> >> > >> >> > this produces: >> >> > >> >> > Content-Typetext/html; charset=iso-8859-1title keywords >> >> > >> >> > I what to be able to get first meta tag "name" attribute which is >> >> "*keywords >> >> > *" >> >> > >> >> > many thanks again! >> >> > Marlon >> >> >> >> > >> >> >> > >> > > >> > >> >> >> -- >> Thanks! >> >> Marlon M. Mojares >> +639291625097 >> > -- -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com --- You received this message because you are subscribed to the Google Groups "Watir General" group. To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [wtr-general] Re: How to get html meta details
Hi Marlon, I tried the above code and I am getting the following error, Ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:48: stack level too deep (SystemStackError) Watir version: Watir4. Please advise what am I doing wrong here. Thanks, S On Wednesday, 4 November 2009 12:40:40 UTC+5:30, Marlon wrote: > > yes for now this is the best solution I have. > > On 11/4/09, Wesley Chen > wrote: > > Thank you very much. > > Only this way to get the meta data? I think it is not convenient enough. > > > > Thanks. > > Wesley Chen. > > For life, the easier, the better. > > > > > > On Tue, Nov 3, 2009 at 10:41 PM, chandu.tennety > > >wrote: > > > >> > >> Marlon, > >> Your original code works for me: > >> > >> {"Content-Type"=>"text/html; charset=iso-8859-1", "keywords"=>"title"} > >> > >> Chandu > >> > >> On Nov 2, 10:51 pm, Marlon wrote: > >> > I found the part of the solution herehttp:// > >> groups.google.com/group/watir-general/browse_thread/thread/566... > >> > it still did not solve my problem. > >> > > >> > *sample html* > >> > > >> > > >> > > >> > title > >> > > >> > >> > http-equiv="Content-Type"/> > >> > > >> > *ruby file* > >> > > >> > require 'watir' > >> > require 'test/unit' > >> > > >> > class TC_MyTest < Test::Unit::TestCase > >> > > >> > def test_meta_get > >> > $ie = Watir::IE.start('') > >> > d=meta($ie) > >> > puts d > >> > end > >> > > >> > def meta( browser ) > >> > meta = {} > >> > bmeta = > >> > browser.document.body.parentElement.getElementsByTagName( "META" ) > >> > bmeta.each do |i| > >> > k = i.name > >> > if k == "" > >> > k = i.httpEquiv > >> > end > >> > meta[ k ] = i.content > >> > end > >> > return meta > >> > end > >> > end > >> > > >> > this produces: > >> > > >> > Content-Typetext/html; charset=iso-8859-1title keywords > >> > > >> > I what to be able to get first meta tag "name" attribute which is > >> "*keywords > >> > *" > >> > > >> > many thanks again! > >> > Marlon > >> > >> > > >> > > > > > > > > > > -- > Thanks! > > Marlon M. Mojares > +639291625097 > -- -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com --- You received this message because you are subscribed to the Google Groups "Watir General" group. To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[wtr-general] Re: How to get html meta details
yes for now this is the best solution I have. On 11/4/09, Wesley Chen wrote: > Thank you very much. > Only this way to get the meta data? I think it is not convenient enough. > > Thanks. > Wesley Chen. > For life, the easier, the better. > > > On Tue, Nov 3, 2009 at 10:41 PM, chandu.tennety > wrote: > >> >> Marlon, >> Your original code works for me: >> >> {"Content-Type"=>"text/html; charset=iso-8859-1", "keywords"=>"title"} >> >> Chandu >> >> On Nov 2, 10:51 pm, Marlon wrote: >> > I found the part of the solution herehttp:// >> groups.google.com/group/watir-general/browse_thread/thread/566... >> > it still did not solve my problem. >> > >> > *sample html* >> > >> > >> > >> > title >> > >> > > > http-equiv="Content-Type"/> >> > >> > *ruby file* >> > >> > require 'watir' >> > require 'test/unit' >> > >> > class TC_MyTest < Test::Unit::TestCase >> > >> > def test_meta_get >> > $ie = Watir::IE.start('') >> > d=meta($ie) >> > puts d >> > end >> > >> > def meta( browser ) >> > meta = {} >> > bmeta = >> > browser.document.body.parentElement.getElementsByTagName( "META" ) >> > bmeta.each do |i| >> > k = i.name >> > if k == "" >> > k = i.httpEquiv >> > end >> > meta[ k ] = i.content >> > end >> > return meta >> > end >> > end >> > >> > this produces: >> > >> > Content-Typetext/html; charset=iso-8859-1title keywords >> > >> > I what to be able to get first meta tag "name" attribute which is >> "*keywords >> > *" >> > >> > many thanks again! >> > Marlon >> >> > >> > > > > -- Thanks! Marlon M. Mojares +639291625097 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How to get html meta details
Thank you very much. Only this way to get the meta data? I think it is not convenient enough. Thanks. Wesley Chen. For life, the easier, the better. On Tue, Nov 3, 2009 at 10:41 PM, chandu.tennety wrote: > > Marlon, > Your original code works for me: > > {"Content-Type"=>"text/html; charset=iso-8859-1", "keywords"=>"title"} > > Chandu > > On Nov 2, 10:51 pm, Marlon wrote: > > I found the part of the solution herehttp:// > groups.google.com/group/watir-general/browse_thread/thread/566... > > it still did not solve my problem. > > > > *sample html* > > > > > > > > title > > > > > > > > *ruby file* > > > > require 'watir' > > require 'test/unit' > > > > class TC_MyTest < Test::Unit::TestCase > > > > def test_meta_get > > $ie = Watir::IE.start('') > > d=meta($ie) > > puts d > > end > > > > def meta( browser ) > > meta = {} > > bmeta = > > browser.document.body.parentElement.getElementsByTagName( "META" ) > > bmeta.each do |i| > > k = i.name > > if k == "" > > k = i.httpEquiv > > end > > meta[ k ] = i.content > > end > > return meta > > end > > end > > > > this produces: > > > > Content-Typetext/html; charset=iso-8859-1title keywords > > > > I what to be able to get first meta tag "name" attribute which is > "*keywords > > *" > > > > many thanks again! > > Marlon > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How to get html meta details
Marlon, Your original code works for me: {"Content-Type"=>"text/html; charset=iso-8859-1", "keywords"=>"title"} Chandu On Nov 2, 10:51 pm, Marlon wrote: > I found the part of the solution > herehttp://groups.google.com/group/watir-general/browse_thread/thread/566... > it still did not solve my problem. > > *sample html* > > > > title > > > > *ruby file* > > require 'watir' > require 'test/unit' > > class TC_MyTest < Test::Unit::TestCase > > def test_meta_get > $ie = Watir::IE.start('') > d=meta($ie) > puts d > end > > def meta( browser ) > meta = {} > bmeta = > browser.document.body.parentElement.getElementsByTagName( "META" ) > bmeta.each do |i| > k = i.name > if k == "" > k = i.httpEquiv > end > meta[ k ] = i.content > end > return meta > end > end > > this produces: > > Content-Typetext/html; charset=iso-8859-1title keywords > > I what to be able to get first meta tag "name" attribute which is "*keywords > *" > > many thanks again! > Marlon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How to get html meta details
Hi Chen, The code in my blog follows ... code=’ title ’ puts content= code.scan(%r{content=”(.*?)”}im).flatten[0].to_s puts name=code.scan(%r{name=”(.*?)”}im).flatten.to_s Output: title keywords Thanks On Tue, Nov 3, 2009 at 4:31 PM, Wesley Chen wrote: > But I can't access the URL: http://bit.ly/4mDHoJ > How can I make it? > > > Thanks. > Wesley Chen. > For life, the easier, the better. > > > On Tue, Nov 3, 2009 at 4:42 PM, Raveendran P wrote: > >> Hi Marlon, >> >> welcome ... ! >> >> >> On Tue, Nov 3, 2009 at 1:11 PM, Marlon wrote: >> >>> >>> >>> Hi Raveendran, >>> >>> I was able to get what I want. For now im going to use it. >>> >>> thanks lot for helping! >>> >>> marlon >>> >>> >>> >>> >>> >>> >> >> >> -- >> Regards, >> P.Raveendran >> http://raveendran.wordpress.com >> >> >> >> > > > > -- Regards, P.Raveendran http://raveendran.wordpress.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How to get html meta details
But I can't access the URL: http://bit.ly/4mDHoJ How can I make it? Thanks. Wesley Chen. For life, the easier, the better. On Tue, Nov 3, 2009 at 4:42 PM, Raveendran P wrote: > Hi Marlon, > > welcome ... ! > > > On Tue, Nov 3, 2009 at 1:11 PM, Marlon wrote: > >> >> >> Hi Raveendran, >> >> I was able to get what I want. For now im going to use it. >> >> thanks lot for helping! >> >> marlon >> >> >> >> >> >> > > > -- > Regards, > P.Raveendran > http://raveendran.wordpress.com > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How to get html meta details
Hi Marlon, welcome ... ! On Tue, Nov 3, 2009 at 1:11 PM, Marlon wrote: > > > Hi Raveendran, > > I was able to get what I want. For now im going to use it. > > thanks lot for helping! > > marlon > > > > > > > -- Regards, P.Raveendran http://raveendran.wordpress.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How to get html meta details
Hi Raveendran, I was able to get what I want. For now im going to use it. thanks lot for helping! marlon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How to get html meta details
Hi Marlon, If you want* pure RUBY code* for that purpose then please try with this http://bit.ly/4mDHoJ Thanks On Tue, Nov 3, 2009 at 9:21 AM, Marlon wrote: > I found the part of the solution here > http://groups.google.com/group/watir-general/browse_thread/thread/5668eca30fdf784/940aa7f7be28c75d?lnk=gst&q=meta#940aa7f7be28c75dbut > it still did not solve my problem. > > *sample html* > > > > > title > > > > *ruby file* > > require 'watir' > require 'test/unit' > > class TC_MyTest < Test::Unit::TestCase > > def test_meta_get > $ie = Watir::IE.start('') > d=meta($ie) > puts d > end > > def meta( browser ) > meta = {} > bmeta = > browser.document.body.parentElement.getElementsByTagName( "META" ) > bmeta.each do |i| > k = i.name > if k == "" > k = i.httpEquiv > end > meta[ k ] = i.content > end > return meta > end > end > > > this produces: > > Content-Typetext/html; charset=iso-8859-1title keywords > > > I what to be able to get first meta tag "name" attribute which is "* > keywords*" > > > > > many thanks again! > Marlon > > > > > > > > -- Regards, P.Raveendran http://raveendran.wordpress.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How to get html meta details
I found the part of the solution here http://groups.google.com/group/watir-general/browse_thread/thread/5668eca30fdf784/940aa7f7be28c75d?lnk=gst&q=meta#940aa7f7be28c75dbut it still did not solve my problem. *sample html* title *ruby file* require 'watir' require 'test/unit' class TC_MyTest < Test::Unit::TestCase def test_meta_get $ie = Watir::IE.start('') d=meta($ie) puts d end def meta( browser ) meta = {} bmeta = browser.document.body.parentElement.getElementsByTagName( "META" ) bmeta.each do |i| k = i.name if k == "" k = i.httpEquiv end meta[ k ] = i.content end return meta end end this produces: Content-Typetext/html; charset=iso-8859-1title keywords I what to be able to get first meta tag "name" attribute which is "*keywords *" many thanks again! Marlon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How to get html meta details
try searching the list archives. Ive posted code to do it before. Paul On Sat, Oct 24, 2009 at 3:22 AM, Marlon wrote: > > Hi please help how can I get/print the meta details for example in the > code below, content "title" and name "keywords" > > I want to print "title" and "keywords" > > > > title > > > > thanks! > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---