I’m writing a script, and it requires to get a reCAPTCHA challenge with a specified public key, so I though if I opened this with urllib2:
chp = urllib.urlencode(dict({'k': key}))
chg = urllib2.urlopen('http://www.google.com/recaptcha/api/challenge', chp).read()
I could then get the challenge from there and return it, but when it does this I get the error:
urllib2.HTTPError: HTTP Error 405: HTTP method POST is not supported by this URL
How can I solve this?
Use a GET request instead:
As the
urllib2documentation states:You were passing in
chpas POST data by passing it to theurlopenmethod as the second positional argument. Concatenating it to the URL with a?instead makes it a GET request.