概念

URL

Universal Resource Locator ,统一资源定位符。

用处:用来标识互联网资源的唯一地址。

本质:提供了互联网上任一资源地址的通用表示方法。

protocol://host:port/path/file.name?parameter

红色部分合称为domain

如:http://baidu.com/index.html  ftp://example/index.pdf

 

https://www.baidu.com

TLD:顶级域——>com

SLD:二级域——>baidu

子域名:——>www

 

用Python的第三方包 tld,拆分域名信息。

from tld import get_tld, get_fld

url = 'http://www.baidu.com'

print(get_fld(url))
# baidu.com

s = get_tld("http://www.baidu.com", as_object=True)
print(s, s.domain, s.subdomain, s.fld)
print(s.parsed_url, s.parsed_url.scheme, s.parsed_url.netloc)

# com baidu www baidu.com
#
SplitResult(scheme='http', netloc='www.baidu.com', path='', query='', fragment='') http www.baidu.com

 

更多方法

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
  • 2021-11-23
  • 2021-12-19
  • 2021-06-08
猜你喜欢
  • 2021-12-05
  • 2021-07-22
  • 2022-12-23
  • 2021-05-03
  • 2022-12-23
  • 2022-12-23
  • 2021-08-22
相关资源
相似解决方案