|
|
- import socket
- url=input("please input the url:")
- c=socket.gethostbyname(url)
- print(c) #ping
复制代码
制作爬虫爬取补天厂商的时候遇到的问题:1.无法采取json 于是我选用data 正则来匹配名字+ID构造page_href 然后利用Cookie来进入提交漏洞页面去获取最终info_href
2.遇到unicode编码 需要转换为中文,首先type(text)->str于是如下处理:
text.encode('latin-1').decode('unicode_escape')总结:1. str.encode() 把字符串转换为其raw bytes形式;bytes.decode() 把raw bytes转换为字符串形式
2. 遇到类似的编码问题时,先检查响应内容text是什么类型,
如果type(text) is bytes,那么:
text.decode('unicode_escape')
如果type(text) is str,那么:
text.encode('latin-1').decode('unicode_escape')
|
|