C/C++教程

Wad和cchardet

本文主要是介绍Wad和cchardet,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import wad.detection
import cchardet
import requests
url='https://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=%E7%99%BE%E5%8F%98%E5%B0%8F%E6%A8%B1'
#查看网站所用的技术
det=wad.detection.Detector()
print(det.detect(url))

#使用cchardet检测网页编码类型
html=requests.get(url)
result=cchardet.detect(html.content)
print(result)
html.encoding=result['encoding']
print(html.encoding)

#查看网站所有者的信息??? 不可用
# import whois
# imagination=whois.whois("www.douban.com")
# print(imagination)

运行结果:
{'https://wappass.baidu.com/static/captcha/tuxing.html?&ak=5c55ec1d6f983c7c410423a63d2071b6&backurl=https%3A%2F%2Fimage.baidu.com%2Fsearch%2Findex%3Ftn%3Dbaiduimage%26ps%3D1%26ct%3D201326592%26lm%3D-1%26cl%3D2%26nc%3D1%26ie%3Dutf-8%26word%3D%25E7%2599%25BE%25E5%258F%2598%25E5%25B0%258F%25E6%25A8%25B1&logid=8222708050713939226&signature=38fc918feb0204fde084b2f9e1bb71ab&timestamp=1618650782': [{'app': 'Apache', 'ver': None, 'type': 'Web Servers'}]}
{'encoding': 'UTF-8', 'confidence':0.9900000095367432}
UTF-8
这篇关于Wad和cchardet的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!