我向Google提交值的python代码:
from twill.commands import *
go('www.google.com')
showforms()
formclear('1')
fv("1", "q", "python")
showforms()
submit('btnG')
运行时会显示以下错误:
***MissingSchema: Invalid URL u'/search': No schema supplied. Perhaps you meant http:///search?***
答案 0 :(得分:1)
关键是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')
至于让代码实际搜索,我不确定。
您可以使用"http://www.google.com/?q=" + searchFor"