here is my code <br><br># -*- coding: gbk -*-<br>import mechanize<br>import cookielib<br>target="<a href="http://v.163.com/movie/2008/10/O/Q/M7F57SUCS_M7F5R3DOQ.html">http://v.163.com/movie/2008/10/O/Q/M7F57SUCS_M7F5R3DOQ.html</a>"<br>
# Browser<br>br = mechanize.Browser()<br># Cookie Jar<br>cj = cookielib.LWPCookieJar()<br>br.set_cookiejar(cj)<br># Browser options<br>br.set_handle_equiv(True)<br>br.set_handle_gzip(True)<br>br.set_handle_redirect(True)<br>
br.set_handle_referer(True)<br>#br.set_handle_robots(False)<br><br># Follows refresh 0 but not hangs on refresh > 0<br>br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)<br><br># Want debugging messages?<br>
#br.set_debug_http(True)<br>#br.set_debug_redirects(True)<br>#br.set_debug_responses(True)<br><br><br># User-Agent (this is cheating, ok?)<br>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>
br.open(target)<br>web=br.response().read()<br>file=open('c:\\v','w')<br>file.write(web)<br>file.close()<br><br>why i can't get the address of movie??<br>