简体   繁体   English

使用斜纹的python 2.7提交错误

[英]python 2.7 using twill submit error

My python code to submit a value to Google: 我的python代码可向Google提交值:

from twill.commands import *
go('www.google.com')
showforms()
formclear('1')
fv("1", "q", "python")
showforms()
submit('btnG')

When it is run it shows the following error: 运行时,它将显示以下错误:

***MissingSchema: Invalid URL u'/search': No schema supplied. Perhaps you meant http:///search?*** 

The key is formaction('1', 'www.google.com/search') , So in your case: 关键是formaction('1', 'www.google.com/search') ,因此在您的情况下:

from twill.commands import *
go('www.google.com')
showforms()
formclear('1')
fv("1", "q", "python")
formaction('1', 'www.google.com/search')
showforms()
submit('btnG')

As for getting the code to actually search, I'm not sure. 至于不确定要实际搜索的代码,我不确定。

You can do a google search by url with "http://www.google.com/?q=" + searchFor" 您可以使用"http://www.google.com/?q=" + searchFor"通过网址进行Google搜索

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

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