Skip to content

Commit a1b88ed

Browse files
authored
京东商品晒单图下载
京东商品晒单图下载
1 parent 4e3d97e commit a1b88ed

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

dingdong/jd.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ def goods_images(goods_url):
107107
Returns:
108108
image_urls - list 图片链接
109109
"""
110-
# 创建session
111-
sess = requests.Session()
112110
image_urls = []
113111
productId = goods_url.split('/')[-1].split('.')[0]
112+
114113
# 评论url
115114
comment_url = 'https://sclub.jd.com/comment/productPageComments.action'
116115
comment_params = {'productId':productId,
@@ -127,7 +126,7 @@ def goods_images(goods_url):
127126
'Referer':goods_url,
128127
'Host': 'sclub.jd.com'}
129128

130-
comment_req = sess.get(url=comment_url, params=comment_params, headers=comment_headers, verify=False)
129+
comment_req = requests.get(url=comment_url, params=comment_params, headers=comment_headers, verify=False)
131130
html = json.loads(comment_req.text)
132131
# 获得晒图个数
133132
imageListCount = html['imageListCount']
@@ -145,7 +144,7 @@ def goods_images(goods_url):
145144
'pageSize':'10',
146145
'_':now}
147146
club_headers = comment_headers
148-
club_req = sess.get(url=club_url, params=club_params, headers=club_headers, verify=False)
147+
club_req = requests.get(url=club_url, params=club_params, headers=club_headers, verify=False)
149148
html = json.loads(club_req.text)
150149
for img in html['imgComments']['imgList']:
151150
image_urls.append(img['imageUrl'])
@@ -193,7 +192,6 @@ def run(path, keyword, num):
193192
pages = 1
194193
while flag == False:
195194
goods_urls = search_goods(keyword, pages)
196-
print(goods_urls)
197195
if len(goods_urls) > num:
198196
flag = True
199197
else:

0 commit comments

Comments
 (0)