|
@@ -14,33 +14,34 @@ def wx_search(keys, sensitive_words):
|
|
:param keys:
|
|
:param keys:
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- url = "http://8.217.190.241:8888/crawler/wei_xin/keyword"
|
|
|
|
- payload = json.dumps({
|
|
|
|
- "keyword": keys,
|
|
|
|
- "cursor": "0",
|
|
|
|
- "content_type": "video"
|
|
|
|
- })
|
|
|
|
- headers = {
|
|
|
|
- 'Content-Type': 'application/json'
|
|
|
|
- }
|
|
|
|
- response = requests.request("POST", url, headers=headers, data=payload).json()
|
|
|
|
- if response['msg'] == '未知错误':
|
|
|
|
- return []
|
|
|
|
- else:
|
|
|
|
- L = []
|
|
|
|
- if response['data']:
|
|
|
|
- video_list = response['data']['data']
|
|
|
|
- if video_list:
|
|
|
|
- for video in video_list:
|
|
|
|
- try:
|
|
|
|
- video_info = video['items'][0]
|
|
|
|
- title = video_info['title']
|
|
|
|
- duration_str = video_info['duration']
|
|
|
|
- dr = int(duration_str.split(":")[0].strip()) + int(duration_str.split(":")[1].strip())
|
|
|
|
- if sensitive_flag(sensitive_words, title) and dr <= 300:
|
|
|
|
- L.append(video_info)
|
|
|
|
- else:
|
|
|
|
- continue
|
|
|
|
- except:
|
|
|
|
- pass
|
|
|
|
- return L
|
|
|
|
|
|
+ return []
|
|
|
|
+ # url = "http://8.217.190.241:8888/crawler/wei_xin/keyword"
|
|
|
|
+ # payload = json.dumps({
|
|
|
|
+ # "keyword": keys,
|
|
|
|
+ # "cursor": "0",
|
|
|
|
+ # "content_type": "video"
|
|
|
|
+ # })
|
|
|
|
+ # headers = {
|
|
|
|
+ # 'Content-Type': 'application/json'
|
|
|
|
+ # }
|
|
|
|
+ # response = requests.request("POST", url, headers=headers, data=payload).json()
|
|
|
|
+ # if response['msg'] == '未知错误':
|
|
|
|
+ # return []
|
|
|
|
+ # else:
|
|
|
|
+ # L = []
|
|
|
|
+ # if response['data']:
|
|
|
|
+ # video_list = response['data']['data']
|
|
|
|
+ # if video_list:
|
|
|
|
+ # for video in video_list:
|
|
|
|
+ # try:
|
|
|
|
+ # video_info = video['items'][0]
|
|
|
|
+ # title = video_info['title']
|
|
|
|
+ # duration_str = video_info['duration']
|
|
|
|
+ # dr = int(duration_str.split(":")[0].strip()) + int(duration_str.split(":")[1].strip())
|
|
|
|
+ # if sensitive_flag(sensitive_words, title) and dr <= 300:
|
|
|
|
+ # L.append(video_info)
|
|
|
|
+ # else:
|
|
|
|
+ # continue
|
|
|
|
+ # except:
|
|
|
|
+ # pass
|
|
|
|
+ # return L
|