猫史档案馆


【Python作品分享】逗你玩(才怪)【作品秀】

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


【作品展示】

center_image

 

【作品介绍】

来自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


回复

上一页1 页 / 共 1下一页
wrmdcxywrmdcxy

是CSDN对吧

点赞0


评论


草草草草草草

i 是作者,这个号和我发布的号不是一个号。回复一下你的:“yes

点赞0


评论


蒟蒻OIer1048576蒟蒻OIer1048576

不错!good!喵~

点赞0


评论


蒟蒻OIer1048576蒟蒻OIer1048576

顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶

点赞1


评论


蒟蒻OIer1048576蒟蒻OIer1048576

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 = {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


评论