我正在 Ruby on Rails 中使用 rake 任务。我有一个网站,我需要登录才能抓取该网站。我填写了表格。
form[:login] = user_name
form[:pw] = password
form.submit
这会返回错误
#<Mechanize::Page
{url
#<URI::HTTPS:0x007fa36a0037b8 URL:https://pulse2.com/system/JSAuth/NoScript.html>}
{meta_refresh}
{title "You must use a JavaScript capable browser with this site."}
{iframes}
{frames}
{links}
{forms}>
这很奇怪,因为 a) 我可以为 scraper 打开 JS 功能 b) 这是网站本身的问题吗?
[编辑]更多信息。当我查看表格时,它看起来像这样。需要注意的一件事是 {action "/system/JSAuth/NoScript.html"}。我相信这就是我无法提交行动的原因。有没有办法解决这个问题?
#<Mechanize::Form
{name "mainform"}
{method "POST"}
{action "/system/JSAuth/NoScript.html"}
{fields
[hidden:0x3fc5b7d7d8b0 type: hidden name: referer value: ]
[hidden:0x3fc5b7d7d75c type: hidden name: VerLoginAttempt value: 1]
[hidden:0x3fc5b7d7d608 type: hidden name: FormName value: LoginMain]
[text:0x3fc5b7d7d4b4 type: text name: VerLoginID value: ]
[field:0x3fc5b7d7d360 type: password name: VerPassword value: ]}
{radiobuttons}
{checkboxes
[checkbox:0x3fc5b7d7d234 type: checkbox name: RCRememberMe value: false]}
{file_uploads}
{buttons [submit:0x3fc5b7d7d090 type: submit name: value: Login]}>
最佳答案
关于javascript - 抓取外部网站但返回 "You must use a JavaScript capable browser with this site."错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28071251/