I am using urllib.parse and I need to take one query value from a URL. I tried it with one URL and it worked, but parse.qs on the other URL returns an empty dictionary
Code that doesn't work:
from urllib.parse import urlparse
from urllib.parse import parse_qs
url = 'https://newassets.hcaptcha.com/captcha/v1/000919d/static/hcaptcha.html#frame=checkbox&id=0d4abkdnbvpa&host=2captcha.com&sentry=true&reportapi=https%3A%2F%2Faccounts.hcaptcha.com&recaptchacompat=off&custom=false&hl=ru&tplinks=on&sitekey=41b778e7-8f20-45cc-a804-1f1ebb45c579&theme=light&origin=https%3A%2F%2F2captcha.com'
parsed_url = urlparse(url)
captured_value = parse_qs(parsed_url.query)
print(captured_value)
Output:
{}
The code that works:
from urllib.parse import urlparse
from urllib.parse import parse_qs
url = 'http://foo.appspot.com/abc?def=ghi'
parsed_url = urlparse(url)
captured_value = parse_qs(parsed_url.query)
print(captured_value)
Output:
{'def': ['ghi']}