我发现了如何使用教程从谷歌搜索中检索主题的 html 页面。教程中给出了这一点。
import mechanize
br = mechanize.Browser()
br.open('http://www.google.co.in')
br.select_form(nr = 0)
直到这一点我才明白它会检索表单。然后它被赋予了
br.form['q'] = 'search topic'
br.submit()
br.response.read()
这会输出与搜索主题相关的页面的 html。但我的疑问是 br.form[parameter] 中的这个参数应该是什么?因为我在谷歌新闻上试过,结果很成功。有人可以帮我吗?