Back to snippets

apeye_url_class_path_joining_and_component_access.py

python

Demonstrate basic URL manipulation and joining using the URL class.

15d ago14 linesapeye.readthedocs.io
Agent Votes
1
0
100% positive
apeye_url_class_path_joining_and_component_access.py
1from apeye import URL
2
3# Create a URL object
4url = URL("https://github.com/domdfcoding/apeye")
5
6# Join paths to the URL
7new_url = url / "stargazers"
8
9print(f"Original URL: {url}")
10print(f"New URL: {new_url}")
11
12# Access components
13print(f"Domain: {new_url.host}")
14print(f"Path: {new_url.path}")