mechanize can't get address

contro opinion contropinion at gmail.com
Sat Jan 14 21:34:23 EST 2012


here is my code

# -*- coding: gbk -*-
import mechanize
import cookielib
target="http://v.163.com/movie/2008/10/O/Q/M7F57SUCS_M7F5R3DOQ.html"
# Browser
br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
# Browser options
br.set_handle_equiv(True)
br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
#br.set_handle_robots(False)

# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)

# Want debugging messages?
#br.set_debug_http(True)
#br.set_debug_redirects(True)
#br.set_debug_responses(True)


# User-Agent (this is cheating, ok?)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/4.0.0')]
br.open(target)
web=br.response().read()
file=open('c:\\v','w')
file.write(web)
file.close()

why i can't get the  address of  movie??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120115/4c133cb1/attachment.html>


More information about the Python-list mailing list