Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!amsnews11.chello.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'emulate': 0.07; 'mechanize': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:python': 0.10; '(x11;': 0.16; 'i686;': 0.16; 'result:': 0.16; 'rv:1.9.0.1)': 0.16; 'wrote:': 0.16; 'linux': 0.17; 'subject:problem': 0.19; 'cheers,': 0.20; 'code': 0.25; 'skip:[ 10': 0.27; 'import': 0.27; 'problem': 0.29; 'print': 0.29; 'skip:b 20': 0.29; 'url:2012': 0.30; 'suggested': 0.32; "can't": 0.32; 'header:User-Agent:1': 0.33; 'to:addr:python-list': 0.33; 'header:X-Complaints-To:1': 0.34; 'similar': 0.36; 'uses': 0.36; 'received:org': 0.37; 'hello,': 0.37; 'page': 0.37; 'subject:with': 0.38; 'think': 0.38; 'form,': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'url:v': 0.61; 'url:7': 0.67; 'directly.': 0.68; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'url:10': 0.72; 'reply- to:addr:gmail.com': 0.78; 'url:o': 0.88; 'subject::': 0.89 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Kev Dwyer Subject: Re: problem:emulate it in python with mechanize Date: Sun, 15 Jan 2012 14:20:36 +0000 References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: cpc7-hari14-2-0-cust162.20-2.cable.virginmedia.com Mail-Copies-To: kevin.p.dwyer@gmail.com User-Agent: KNode/4.7.2 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: kevin.p.dwyer@gmail.com List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326637253 news.xs4all.nl 6863 [2001:888:2000:d::a6]:41371 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19007 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