forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec27848
commit 007b9b2
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
Retos/Reto #11 - URL PARAMS [Fácil]/python/TiagoAlvarezSchiaffino.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import re | ||
|
||
def ask_url(): | ||
""" | ||
Prompt the user to enter a URL. | ||
Returns: | ||
str: The entered URL. | ||
""" | ||
return input("URL: ") | ||
|
||
def extract_parameters(url): | ||
""" | ||
Extract parameters from the given URL using regular expressions. | ||
Args: | ||
url (str): The URL with parameters. | ||
Returns: | ||
list: A list containing the extracted parameter values. | ||
""" | ||
regex = r"([a-zA-Z0-9._%-]+)" | ||
params = re.findall(regex, url) | ||
return params | ||
|
||
def main(): | ||
""" | ||
Main function to execute the program. | ||
""" | ||
url = ask_url() | ||
parameters = extract_parameters(url) | ||
|
||
print(f"The parameters from the URL are: {parameters}") | ||
|
||
if __name__ == "__main__": | ||
main() |