这是Get protocol + host name from URL的扩展,添加了一个要求,即我只需要域名,而不是子域。在
比如说
Input: classes.usc.edu/xxx/yy/zz
Output: usc.edu
Input: mail.google.com
Output: google.com
Input: google.co.uk
Output: google.co.uk
对于更多的上下文,我接受用户的一个或多个种子url,然后在链接上运行一个垃圾爬虫程序。我需要域名(不带子域)来设置allowed_urls
属性。在
我也看了Python urlparse -- extract domain name without subdomain,但那里的答案似乎过时了。在
我当前的代码使用urlparse
,但这也得到了我不想要的子域。。。在
在python-3.x中是否有一种(希望是stdlib)方法(只获取)域?在
我在进行域解析时使用
tldextract
。在在您的例子中,您只需要组合
domain
+suffix
相关问题 更多 >
编程相关推荐