|
@@ -0,0 +1,17 @@
|
|
1
|
+from urllib.parse import urlparse
|
|
2
|
+from yarl import URL
|
|
3
|
+
|
|
4
|
+print(URL('https://swhacademy.ga')) # URL('swhacademy.ga')
|
|
5
|
+url = 'http://user:pass@example.com:8042/over/there?name=ferret#nose'
|
|
6
|
+urllib_url = urlparse(url)
|
|
7
|
+yarl_url = URL(url)
|
|
8
|
+
|
|
9
|
+print(yarl_url.scheme) # 'http'print(urllib_url.scheme) # 'http'
|
|
10
|
+print(yarl_url.user) # 'user'print(urllib_url.username) # 'user'
|
|
11
|
+print(yarl_url.password) # 'pass'print(urllib_url.password) # 'pass'
|
|
12
|
+print(yarl_url.host) # 'example.com'print(urllib_url.hostname) # 'example.com'
|
|
13
|
+print(yarl_url.port) # 8042print(urllib_url.port) # 8042
|
|
14
|
+print(yarl_url.path) # '/over/there'print(urllib_url.path) # '/over/there'
|
|
15
|
+print(yarl_url.query_string) # 'name=ferret'print(urllib_url.query) # 'name=ferret'
|
|
16
|
+print(yarl_url.query) # <MultiDictProxy('name': 'ferret')># urllib에는 없음
|
|
17
|
+print(yarl_url.fragment) # 'nose'print(urllib_url.fragment) # 'nose'
|