python에서 URL을 파싱하려면 urllib.parse 모듈의 urlsplit 함수를 사용한다. urlsplit 함수는 URL을 각 구성 요소로 분리한다.
>>> from urllib.parse import urlsplit
>>> components = urlsplit('http://example.webscraping.com/places/default/view')
>>> print(components)
SplitResult(scheme='http', netloc='example.webscraping.com', path='/places/default/view', query='', fragment='')
>>> print(components.path)
/places/default/view
'python' 카테고리의 다른 글
파이썬의 선(Zen of Python) (0) | 2018.09.23 |
---|---|
[python] pickle 예시 (0) | 2018.09.12 |
파이썬 모듈 프로그래밍 예시 - __init__.py (0) | 2018.09.07 |
[python] whois 모듈 (0) | 2018.09.03 |
[python] OptionParser 활용하는 사례 (0) | 2018.07.04 |