contro opinion wrote: > you can do it by hand , > 1.open > http://www.flvcd.com/' > 2.input > http://v.163.com/movie/2008/10/O/Q/M7F57SUCS_M7F5R3DOQ.html > 3.click submit > you can get > http://mov.bn.netease.com/movie/2012/1/V/7/S7MKQOBV7.flv > > i want to emulate it in python with mechanize,here is my code ,why i > can't get the right result: > http://mov.bn.netease.com/movie/2012/1/V/7/S7MKQOBV7.flv > > > > import mechanize > import cookielib > import lxml.html > 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/3.0.1')] > br = mechanize.Browser() > br.set_handle_robots(False) > > r = br.open('http://www.flvcd.com/') > for f in br.forms(): > print f > br.select_form(nr=0) > br.form['kw']='http://v.163.com/movie/2008/10/O/Q/M7F57SUCS_M7F5R3DOQ.html' > print br.submit().read() > > why??
Hello, I think the page uses javascript to submit the form, so mechanize may not work with it directly. See http://stackoverflow.com/questions/3798550/python-mechanize-javascript- submit-button-problem for a similar problem and suggested workaround. Cheers, Kev -- http://mail.python.org/mailman/listinfo/python-list