あり、あなたがテキストを入力する必要があります入力フィールドでは、のようなものを使用A Mechanizeのを使用して、この例に見て:それは基本的なアイデアを与えるだろう。
#!/usr/bin/python
import re
from mechanize import Browser
br = Browser()
# Ignore robots.txt
br.set_handle_robots(False)
# Google demands a user-agent that isn't a robot
br.addheaders = [('User-agent', 'Firefox')]
# Retrieve the Google home page, saving the response
br.open("http://google.com")
# Select the search box and search for 'foo'
br.select_form('f')
br.form[ 'q' ] = 'foo'
# Get the search results
br.submit()
# Find the link to foofighters.com; why did we run a search?
resp = None
for link in br.links():
siteMatch = re.compile('www.foofighters.com').search(link.url)
if siteMatch:
resp = br.follow_link(link)
break
# Print the site
content = resp.get_data()
print content
を、私は、しかしPythonの2.6を使用してこだわっているので、悲しいことにMechanizeのは、いずれかのオプションではありません。 (GopherErrorは2.6で落としたように見える)。 – Habaabiai
機械化されたドキュメントは、通常少し軽いですが、実際には本当に素晴らしいです! –
私はあなたが主張するべきだと思う、ゴーファーの問題をデバッグしてみてください。 Python 2.6では、gopherサポートがIIRCから削除されました。あなたの問題を修正することは、おそらくimport gopherlibとgopherが実際に使用されるいくつかの箇所についてコメントすることです。 –