Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19007 > unrolled thread
| Started by | Kev Dwyer <kevin.p.dwyer@gmail.com> |
|---|---|
| First post | 2012-01-15 14:20 +0000 |
| Last post | 2012-01-15 14:20 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: problem:emulate it in python with mechanize Kev Dwyer <kevin.p.dwyer@gmail.com> - 2012-01-15 14:20 +0000
| From | Kev Dwyer <kevin.p.dwyer@gmail.com> |
|---|---|
| Date | 2012-01-15 14:20 +0000 |
| Subject | Re: problem:emulate it in python with mechanize |
| Message-ID | <mailman.4771.1326637253.27778.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web