Skip to content

Commit

Permalink
更新保存cookie的方法
Browse files Browse the repository at this point in the history
  • Loading branch information
duolabmeng6 committed Nov 30, 2023
1 parent 3b56896 commit 1589d28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyefun/核心易函数支持库/网络请求.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ def __init__(self, cookies文件路径="", 访问失败重试次数=0, 全局头

def __del__(self):
if self.cookies文件路径 != "":
if 文件是否存在(self.cookies文件路径) == False:
文件_写出(self.cookies文件路径, "")

self.req.cookies.save()

def 设置自动管理cookies(self, 文件路径):
Expand Down
4 changes: 4 additions & 0 deletions pyefun/核心易函数支持库/网络请求_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ def test_header(self):
ehttp = eRequests()
url = 'https://fanyi.baidu.com'
ehttp.get(url, 附加头信息=headers)

def test_cooie(self):
ehttp = eRequests(cookies文件路径="./cookie/1.cookie")
ehttp.get("https://www.baidu.com")

0 comments on commit 1589d28

Please sign in to comment.