@@ -107,10 +107,9 @@ def goods_images(goods_url):
107
107
Returns:
108
108
image_urls - list 图片链接
109
109
"""
110
- # 创建session
111
- sess = requests .Session ()
112
110
image_urls = []
113
111
productId = goods_url .split ('/' )[- 1 ].split ('.' )[0 ]
112
+
114
113
# 评论url
115
114
comment_url = 'https://sclub.jd.com/comment/productPageComments.action'
116
115
comment_params = {'productId' :productId ,
@@ -127,7 +126,7 @@ def goods_images(goods_url):
127
126
'Referer' :goods_url ,
128
127
'Host' : 'sclub.jd.com' }
129
128
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 )
131
130
html = json .loads (comment_req .text )
132
131
# 获得晒图个数
133
132
imageListCount = html ['imageListCount' ]
@@ -145,7 +144,7 @@ def goods_images(goods_url):
145
144
'pageSize' :'10' ,
146
145
'_' :now }
147
146
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 )
149
148
html = json .loads (club_req .text )
150
149
for img in html ['imgComments' ]['imgList' ]:
151
150
image_urls .append (img ['imageUrl' ])
@@ -193,7 +192,6 @@ def run(path, keyword, num):
193
192
pages = 1
194
193
while flag == False :
195
194
goods_urls = search_goods (keyword , pages )
196
- print (goods_urls )
197
195
if len (goods_urls ) > num :
198
196
flag = True
199
197
else :
0 commit comments