import mechanize URL = 'http://yoururl.com' br = mechanize.Browser() br.set_handle_robots() #这一句是用来绕过那些防止机器爬虫的网站的设置 response = br.open(URL) sourcecode = response.read()