摘要: import requests url = 'https://movie.douban.com/' r = requests.get(url) # r.cookies 是RequestsCookieJar对象 print(r.cookies) mycookies = r.cookies # Requ 阅读全文
posted @ 2021-06-23 13:02 自己的阿毛 阅读(556) 评论(0) 推荐(0) 编辑
摘要: import urllib.request import urllib.parse bianma = '编程' one = urllib.parse.quote(bianma) print(one) two = urllib.parse.quote(one) print(two) three = u 阅读全文
posted @ 2021-06-22 21:43 自己的阿毛 阅读(25) 评论(0) 推荐(0) 编辑
摘要: import urllib.request import urllib.parse headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) 阅读全文
posted @ 2021-06-22 21:34 自己的阿毛 阅读(36) 评论(0) 推荐(0) 编辑
摘要: import urllib.request import ssl # 关闭ssl证书验证(固定写法) ssl._create_default_https_context = ssl._create_unverified_context url = 'https://inv-veri.chinatax 阅读全文
posted @ 2021-06-22 21:18 自己的阿毛 阅读(346) 评论(0) 推荐(0) 编辑
摘要: import urllib.request from http import cookiejar filename = 'cookie.txt' # 创建MoillaCookiejar对象 cookie = cookiejar.MozillaCookieJar() # 读取cookie变量 cook 阅读全文
posted @ 2021-06-22 21:08 自己的阿毛 阅读(70) 评论(0) 推荐(0) 编辑
摘要: 目前还没看懂,mozillacookiejar 啥子意思 网上都是基本上是复制粘贴的,没讲明白。 所以就死记硬背吧。 记住民工三连: cookie = cookiejar.Mozillacookiejar(filename) handler = urllib.request.HTTPCookiePr 阅读全文
posted @ 2021-06-22 20:50 自己的阿毛 阅读(91) 评论(0) 推荐(0) 编辑
摘要: urllib.request.ProxyHandler() 可以动态设置代理IP池 urllib.request.build_opener() 将代理IP池中的ip写入该方法生成opener opener.open(url) 打开url 代码如下: # 导入urllib import urllib. 阅读全文
posted @ 2021-06-21 23:38 自己的阿毛 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 上一个随笔中报错: urllib.error.HTTPError: HTTP Error 418: 百度后,加上头部得以解决。 urllib.request.Request 功能:声明一个request对象。可自定义header等请求信息。 本次,加入一个更多参数的header。 # 导入urlli 阅读全文
posted @ 2021-06-21 23:22 自己的阿毛 阅读(341) 评论(0) 推荐(0) 编辑
摘要: 语法 urllib.request.urlopen 意思就是打开 url # 导入urllib import urllib.request # 打开url response = urllib.request.urlopen('https://movie.douban.com/', None, 10) 阅读全文
posted @ 2021-06-21 23:09 自己的阿毛 阅读(457) 评论(0) 推荐(0) 编辑
摘要: 在写图书管理系统的时候遇到需要将管理员页面和普通用户页面分离。普通用户无法访问管理员页面。于是想用装饰器。 def check_login(func): @login_required(login_url='/account/login/') #装饰器嵌套 def wrapper(request,* 阅读全文
posted @ 2020-12-15 22:16 自己的阿毛 阅读(119) 评论(0) 推荐(0) 编辑