如何使用 Mechanize 处理 JavaScript? [英] How do I use Mechanize to process JavaScript?

查看:28
本文介绍了如何使用 Mechanize 处理 JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在连接到一个网站,正在登录.

I'm connecting to a web site, logging in.

该网站将我重定向到新页面,Mechanize 处理所有 cookie 和重定向作业,但是,我无法获取最后一页.我使用了 Firebug 并再次做了同样的工作,发现我不得不使用 Mechanize 传递另外两个页面.

The website redirects me to new pages and Mechanize deals with all cookie and redirection jobs, but, I can't get the last page. I used Firebug and did same job again and saw that there are two more pages I had to pass with Mechanize.

我快速浏览了页面,看到有一些 JavaScript 和 HTML 代码,但无法理解,因为它看起来不像正常的页面代码.这些页面是做什么用的?他们如何重定向到其他页面?我该怎么做才能通过这些?

I took a quick look at the pages and saw that there is some JavaScript and HTML code but couldn't understand it because it doesn't look like normal page code. What are those pages for? How they can redirect to other pages? What should I do to pass these?

推荐答案

如果您需要使用 Javascript 处理页面,请尝试 WATIRSelenium - 这些驱动真正的网络浏览器,因此可以处理任何 Javascript.WATIR Classic 需要安装特定扩展程序的 IE 或 Firefox,您会看到页面在运行时在屏幕上闪烁.

If you need to handle pages with Javascript, try WATIR or Selenium - those drive a real web browser, and can thus handle any Javascript. WATIR Classic requires either IE or Firefox with a certain extension installed, and you will see the pages flash on the screen as it works.

您的另一个选择是了解违规页面上的 Javascript 的作用并手动绕过它,但这似乎很麻烦.

Your other option would be understanding what the Javascript on the offending page does and bypassing it manually, but that seems onerous.

这篇关于如何使用 Mechanize 处理 JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆