|
@@ -1,4 +1,4 @@
|
1
|
|
-import requests,json,random,execjs,uuid
|
|
1
|
+import requests,json,random,execjs,uuid,os
|
2
|
2
|
from urllib import parse
|
3
|
3
|
from urllib.parse import quote
|
4
|
4
|
from libs.proxy import Proxy
|
|
@@ -9,14 +9,14 @@ class WebDouYin:
|
9
|
9
|
self.proxies = {
|
10
|
10
|
}
|
11
|
11
|
def get_signature(self,url=None,method='_signature'):
|
12
|
|
- with open('/mnt/shop_live_scraper/signature.js', 'r', encoding='utf-8') as f:
|
|
12
|
+
|
|
13
|
+ with open(os.getcwd()+"/signature.js", 'r', encoding='utf-8') as f:
|
13
|
14
|
b = f.read()
|
14
|
15
|
|
15
|
16
|
c = execjs.compile(b)
|
16
|
17
|
|
17
|
18
|
# url=url.replace('%28','(').replace('%29',')').replace('%2C',',')
|
18
|
19
|
d = c.call(method, url.replace('\n',''))
|
19
|
|
-
|
20
|
20
|
# print('_signature',d)
|
21
|
21
|
return d
|
22
|
22
|
def get_ck(self, proxy=None):
|
|
@@ -144,6 +144,7 @@ class WebDouYin:
|
144
|
144
|
'browser_version':ua.replace('Mozilla/',''),
|
145
|
145
|
'browser_online': 'true',
|
146
|
146
|
}
|
|
147
|
+
|
147
|
148
|
url = url + parse.urlencode(param)
|
148
|
149
|
_signature = self.get_signature(url)
|
149
|
150
|
url+='&_signature='+quote(_signature)
|
|
@@ -160,6 +161,7 @@ class WebDouYin:
|
160
|
161
|
"user-agent":ua,
|
161
|
162
|
"withcredentials": "true",
|
162
|
163
|
}
|
|
164
|
+
|
163
|
165
|
if ck:headers['cookie']=ck
|
164
|
166
|
json_data=self.response(url=url,headers=headers,proxy=proxy)
|
165
|
167
|
return json_data
|
|
@@ -167,8 +169,7 @@ if __name__ == '__main__':
|
167
|
169
|
webdy=WebDouYin()
|
168
|
170
|
# res = webdy.get_user_videos('MS4wLjABAAAAqLPgx-hHf27EqGEtRQ6YyuQQTmikB5CBO1jXy61yhWKujGd8KO5G8V2vdcLQJAym')
|
169
|
171
|
# print(res)
|
170
|
|
- # webdy.get_user_info('MS4wLjABAAAAC2euvL-0qMZyd80aNwZa-wX5KXuz_r7YVNHSBOogfVg')
|
171
|
|
-
|
|
172
|
+ info = webdy.get_user_info('MS4wLjABAAAAHYNHFpUR36AQSxdDpSFrI2uM4aDvSF-8vjtjNiLepD0')
|
172
|
173
|
proxy = Proxy.get()
|
173
|
174
|
print(proxy)
|
174
|
175
|
proxies = {
|
|
@@ -176,4 +177,5 @@ if __name__ == '__main__':
|
176
|
177
|
"https": "http://" + proxy
|
177
|
178
|
}
|
178
|
179
|
|
179
|
|
- ck = webdy.get_ck()
|
|
180
|
+# ck = webdy.get_user_info("MS4wLjABAAAAC2euvL-0qMZyd80aNwZa-wX5KXuz_r7YVNHSBOogfVg")
|
|
181
|
+# print(ck)
|