Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19007
| From | Kev Dwyer <kevin.p.dwyer@gmail.com> |
|---|---|
| Subject | Re: problem:emulate it in python with mechanize |
| Date | 2012-01-15 14:20 +0000 |
| References | <CA+YdQ_6fhZO-3nEeTGmfK7gPOCK0g2b-PbGJXUHr-z=LDdeOkA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4771.1326637253.27778.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: problem:emulate it in python with mechanize Kev Dwyer <kevin.p.dwyer@gmail.com> - 2012-01-15 14:20 +0000
csiph-web