1 Star 0 Fork 185

东方甲乙木 / Python爬虫

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
判断网页编码的程序 2.06 KB
一键复制 编辑 原始数据 按行查看 历史
import urllib.request as r
import chardet as c
while True:
w=input('请问您需要查询的网站是什么编码格式的呢: 0是http 1是https呢:')
q=['http://','https://']
a=input('请输入网址(URL):')
if w =='0':
yy=q[0]+a
res = r.urlopen(yy)
if w =='1':
ww=q[1]+a
res = r.urlopen(ww)
html=res.read()
test=c.detect(html)
print('此网站的编码格式为:',test['encoding'])
b=input('是否继续判断 0是 1不是')
if b =='0':
print('请您继续输入')
if b =='1':
break
Python
1
https://gitee.com/softwyy/python_reptilian.git
git@gitee.com:softwyy/python_reptilian.git
softwyy
python_reptilian
Python爬虫
master

搜索帮助