使用Python 内置的模块 urlparse

from urlparse import *
url = 'https://docs.google.com/spreadsheet/ccc?key=blah-blah-blah-blah#gid=1'
result = urlparse(url)

result 包含了URL的所有信息

 

>>> from urlparse import *
>>> url = 'https://docs.google.com/spreadsheet/ccc?key=blah-blah-blah-blah#gid=1'
>>> result = urlparse(url)
>>> print result
ParseResult(scheme='https', netloc='docs.google.com', path='/spreadsheet/ccc', params='', query='key=blah-blah-blah-blah', fragment='gid=1')
>>> url='http://pkunews.pku.edu.cn/xwzh/2018-04/29/content_302272.htmhttp://pkunews.pku.edu.cn/xwzh/2018-04/29/content_302272.htm' 
>>> result = urlparse(url)
>>> print result
ParseResult(scheme='http', netloc='pkunews.pku.edu.cn', path='/xwzh/2018-04/29/content_302272.htmhttp://pkunews.pku.edu.cn/xwzh/2018-04/29/content_302272.htm', params='', query='', fragment='')

 

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: python