Last active
July 5, 2021 16:33
-
-
Save imran-parray/4dc9f86ecd08aee6569e97a3c594eaea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data=['http://google.com?param1=value1', | |
'https://hello.com?param2=1¶m3=3', | |
'https://hello.com?param1=1¶m2=2¶m4=4'] | |
final_params=[] | |
all_prms=[] | |
for line in data: | |
all_prms.append(line.split('?')[1:][0].split('&')) | |
for line in all_prms: | |
for l in line: | |
final_params.append(l.split('=')[0]) | |
unique_final=list(dict.fromkeys(final_params)) | |
print(unique_final) |
devl00p
commented
May 1, 2020
•
# Shorter one from urllib.parse import parse_qs, urlparse data=['http://google.com?param1=value1', 'https://hello.com?param2=1¶m3=3', 'https://hello.com?param1=1¶m2=2¶m4=4'] print({param for url in data for param in parse_qs(urlparse(url).query)}
Amazing !!
Thanks alot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment