python 识别拼多多,天猫,淘宝,京东域名

今天遇到问题批量链接怎么识别?

直接上代码!

python 识别拼多多,天猫,淘宝,京东域名

import re
from urllib.parse import urlparse

# 获取域名的url
def get_host( url):
    url_dic = urlparse(url)
    return url_dic.netloc

# 识别域名
def show(nu):
    # 京东商品链接
    num = nu
    print(num)
    hots = get_host(nu)
    print(hots)


    print('爬取成功')
if __name__ == "__main__":
    tk = show('https://item.jd.com/29226209677.html')

运行结果

猜你喜欢

转载自blog.csdn.net/weixin_37254196/article/details/106216104