更新时间:2023-02-23 21:31:53
urlparse.urlparse
将 URL 拆分为协议、位置、端口等,然后可以通过 拆分位置.
获取子域.
urlparse.urlparse
will split the URL into protocol, location, port, etc. You can then split the location by .
to get the subdomain.
url = urlparse.urlparse(address)
subdomain = url.hostname.split('.')[0]