网站的提交按钮本地化时使用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?
预先感谢
我的代码要旨:
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.
使用斜纹纸的formaction()函数设置所需页面的操作.例如
use the twill's formaction() function to set the action for the page you want. 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/')
或者您的情况
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')
这篇关于网站的提交按钮本地化时使用Twill的提交功能(Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!