简体   繁体   English

网站的提交按钮本地化时使用Twill的提交功能(Python)

[英]Using Twill's submit function when website's submit button is localized(Python)

I am trying to pull information from a website, and doing so requires me to log into it. 我试图从网站上获取信息,并且这样做需要我登录。 All goes well until I reach the submit button: 一切顺利,直到我到达“提交”按钮为止:

MissingSchema: Invalid URL u'/index.php?r=site/login': No schema supplied. 
Perhaps you meant http:///index.php?r=site/login?

From what I can understand, this is happening because the website redirects itself to a page on the server. 据我了解,这是因为网站将自身重定向到服务器上的页面而发生的。 Is there a way to make the button redirect to the full page instead of a local file on the server? 有没有一种方法可以使按钮重定向到整个页面,而不是服务器上的本地文件? Or am I even correct on why this error is occuring? 还是我什至正确为什么会出现此错误?

Thanks In Advance 提前致谢

The Gist of My Code: 我的代码要点:

from twill.commands import *
go('panel.picklehosting.com/index.php?r=site/login')
showforms()
formclear('1')
fv("1", "name", "usrname")
fv("1", "password", "mypass")
submit()

I've been experiencing the same issue for a site I'm creating but I think I've solved it. 对于我正在创建的网站,我一直遇到同样的问题,但是我想我已经解决了。

use the twill's formaction() function to set the action for the page you want. 使用斜纹纸的formaction()函数设置所需页面的操作。 For example 例如

    from twill.commands import *
    go('http://example.com/login')
    showforms() 
    fv("1", "nameField", "username")
    fv("1", "password", "password")
    formaction('form','http://example.com/login')
    submit("4")
    show()
    go('http://example.com/admin/')

or in your case 还是你的情况

from twill.commands import *
go('panel.picklehosting.com/index.php?r=site/login')
showforms()
formclear('1')
fv("1", "name", "usrname")
fv("1", "password", "mypass")
formaction('form','panel.picklehosting.com/index.php?r=site/login')
submit()
go('panel.picklehosting.com/yourpage.php')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM