Skip to content

Commit

Permalink
初始化Cookie时判断cookies目录是否存在
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghyw committed Dec 21, 2020
1 parent fbccc95 commit cecb717
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions jd_spider_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ def __seckill(self):

def _load_cookies(self):
cookies_file = ''
for name in os.listdir('./cookies'):
if name.endswith('.cookies'):
cookies_file = './cookies/{0}'.format(name)
break
if os.path.exists('./cookies'):
for name in os.listdir('./cookies'):
if name.endswith('.cookies'):
cookies_file = './cookies/{0}'.format(name)
break
if cookies_file == '':
return
with open(cookies_file, 'rb') as f:
Expand Down

0 comments on commit cecb717

Please sign in to comment.