Mechanize is a handy, high level, programmatic web browser type deal for Python. Use it for all of your screen scraping needs. Here are a few tips I had to figure out on my own:
How to set the user agent:
from mechanize import Browser
browser = Browser()
browser.addheaders = [("User-agent", "Mozilla/5.0 (compatible;
MyProgram/0.1)")]
browser.open('http://www.python.org')
How to see the data you’ve fetched:
from mechanize import Browser
browser = Browser()
browser.open('http://www.python.org')
print browser.response().read()
Posted by Greg Pinero (Primary Searcher) in Python
RSS 2.0