M
M
MichaelMih2021-07-14 12:40:28
Python
MichaelMih, 2021-07-14 12:40:28

How to get parameter value from url?

Good day.
Let's say we have the following url:

https://vk.com/markeloff_001?z=photo356270827_457254345%2Fphotos356270827

How to get everything after Z from it?
Or like this:
https://vk.com/feed?w=wall-159908458_143626
Get everything after w.
I don’t know how to do it

and also translate all characters from the url by type (% 2F ) into normal letters

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-07-14
@MichaelMih

import urllib.parse as urlparse
from urllib.parse import parse_qs
url = 'https://vk.com/markeloff_001?z=photo356270827_457254345%2Fphotos356270827'
parsed = urlparse.urlparse(url)
print(parse_qs(parsed.query)['z'])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question