regex - Python - Split url into its components -
i have huge list of urls this:
http://www.example.com/site/section1/var1/var2
where var1 , var2 dynamic elements of url. want extract url string var1. i've tried use urlparse output this:
parseresult(scheme='http', netloc='www.example.com', path='/site/section1/var1/var2', params='', query='', fragment='')
alternatively, can apply split()
method:
>>> url = "http://www.example.com/site/section1/var1/var2" >>> url.split("/")[-2:] ['var1', 'var2']
Comments
Post a Comment