用户:
我是一个变量他使用Python做的查看:4 回复:5 评论:4 创建时间:2020-04-10T11:25:48
【作品展示】

【作品介绍】
来自C啥博客的大蛇王创意改变的。他可以干一些了解网页cookies之列的事情,没有一些Python基础是没法看懂的
【作品源代码】
from urllib import request
from http import cookiejar
import json
from easygui import ynbox
from easygui import enterbox
import requests
if __name__ == '__main__':
cookie = cookiejar.CookieJar()
handler = request.HTTPCookieProcessor(cookie)
GUI = request.build_opener(handler)
p = enterbox("输入你要爬的网址")
r = GUI.open(p)
x = {}
for item in cookie:
x[str(item.name)] = str(item.value)
print(x)
t = ynbox("是否获得网页,headers,状态码")
if t == True:
q = requests.get(p)
start = q.status_code
head = q.headers
print(str([str(x), str(start), str(head)]))
with open("cookies.txt", "a") as f:
f.write(str([str(x),str(start),str(head)]))
print("第一个是cookies,第二个是网页状态码,200正常,403异常,第三个是网页请求头")
else:
with open("cookies.txt", "a") as f:
f.write(str(x))
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn
蒟蒻OIer1048576顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶
点赞1
评论
蒟蒻OIer1048576from urllib import request
from http import cookiejar
import json
from easygui import ynbox
from easygui import enterbox
import requests
if __name__ == '__main__':
cookie = cookiejar.CookieJar()
handler = request.HTTPCookieProcessor(cookie)
GUI = request.build_opener(handler)
p = enterbox("输入你要爬的网址")
r = GUI.open(p)
x = {item.name for item in cookie: item.value for item in cookie}
print(x)
t = ynbox("是否获得网页,headers,状态码")
if t:
q = requests.get(p)
start = q.status_code
head = q.headers
print(str([str(x), str(start), str(head)]))
with open("cookies.txt", "a") as f:
f.write(str([str(x),str(start),str(head)]))
print("第一个是cookies,第二个是网页状态码,200正常,403异常,第三个是网页请求头")
else:
with open("cookies.txt", "a") as f:
f.write(str(x))点赞0
评论