Python Submit Post Data Using Mechanize
The url that i have to submit to the server looks like this: www.mysite.com/manager.php?checkbox%5B%5D=5&checkbox%5B%5D=4&checkbox%5B%5D=57&self=19&submit=Go%21 Th
Solution 1:
You double-encoded the checkbox field names; you should use checkbox[]
instead of checkbox%5B%5D
. Also, because that key name is reused, you probably can't use a dictionary to gather up the arguments.
Solution 2:
Url encoding is the process of changing string (i.e '[]') into percent-encoded string (i.e '%5B%5D') and url decoding is the opposite operation. So:
checkbox%5B%5D=5&checkbox%5B%5D=4&checkbox%5B%5D=57&self=19&submit=Go%21
is after decoding:
checkbox[]=5&checkbox[]=4&checkbox[]=57&self=19&submit=Go!
In your code you're actually encofing an already-encoded url:
data = {'checkbox%5B%5D': '4', ....and so on... 'self': '19', 'submit': 'Go%21'}
data = urllib.urlencode(orbs)
Instead use decoded data and pass it to urlencode:
data = {'checkbox[]': '4', ....and so on... 'self': '19', 'submit': 'Go!'}
data = urllib.urlencode(orbs)
Post a Comment for "Python Submit Post Data Using Mechanize"