0

我的 python 代码向 Google 提交值:

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?*** 
4

1 回答 1

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')

至于让代码实际搜索,我不确定。

您可以通过 url 进行谷歌搜索"http://www.google.com/?q=" + searchFor"

于 2015-03-11T15:04:28.320 回答