How to Get the Page Source with Mechanize/Nokogiri

心不动则不痛 提交于 2019-12-04 16:30:57

问题


I'm logged into a webpage/servlet using Mechanize.

I have a page object

jobShortListPg = agent.get(addressOfPage)

When i use the following

puts jobShortListPg

I get the "mechanized" version of the page which I don't want e.g.

#<Mechanize::Page::Link "Home" "blahICScriptProgramName=WEBLIB_MENU.ISCRIPT3.FieldFormula.IScript_DrillDown&target=main0&Level=0&RL=&navc=3171">

How do I get the html source of the page instead?


回答1:


Use .body

puts jobShortListPg.body



回答2:


Use the content method of the page object.

jobShortListPg.content


来源:https://stackoverflow.com/questions/6487101/how-to-get-the-page-source-with-mechanize-nokogiri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!