Commit 999f94f2 authored by 段英荣's avatar 段英荣

增大并发

parent 26c05f94
......@@ -40,7 +40,8 @@ from gevent import monkey; monkey.patch_socket()
import gevent
from threading import Thread, Lock
import urllib.parse
import hashlib
import random
mutex_for_get_query_word = Lock()
......@@ -365,11 +366,12 @@ class ZhihuAccount(object):
def zhihu_query_by_word(self,query_word,zhihu_spider_fd,zhihu_spider_question_fd,question_answer_dict,cur_word_index):
try:
cur_image_index = 0
for begin_index in range(0, 100, 10):
for begin_index in range(0, 50, 10):
# query_by_word_url = "https://www.zhihu.com/api/v4/search_v3?t=general&correction=1&lc_idx=62&" \
# "show_all_topics=0&search_hash_id=1dbb1e923a17f147356177932d1236e1&" \
# "vertical_info=0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C1" + "&q=" + str(query_word) + "&offset=" + str(begin_index) + "&limit=10"
search_hash_id = hashlib.md5(str(random.random()).encode()).hexdigest()
query_by_word_url = "https://www.zhihu.com/api/v4/search_v3?"
query_params_dict = {
"q": query_word,
......@@ -377,7 +379,7 @@ class ZhihuAccount(object):
"limit": 10,
"lc_idx": 22,
"show_all_topics": 0,
"search_hash_id": "1dbb1e923a17f147356177932d1236e1",
"search_hash_id": search_hash_id,
"vertical_info": "0,0,0,0,0,0,0,0,0,1",
"correction": 1,
"t": "general"
......@@ -479,7 +481,7 @@ class ZhihuAccount(object):
# 知乎问题对应的回答列表
def zhihu_answers_list_by_question(self,question_id,question_answer_dict,zhihu_spider_fd,cur_image_index,cur_word_index):
for begin_index in range(0,100,10):
for begin_index in range(0,20,10):
# answers_list_by_question_url = "https://www.zhihu.com/api/v4/questions/" + str(question_id) + \
# "/answers?include=data%5B*%5D.is_normal%2Cadmin_closed_comment%2Creward_info%2Cis_collapsed%2Cannotation_action%2Cannotation_detail%2Ccollapse_reason%2Cis_sticky%2Ccollapsed_by%2Csuggest_edit%2Ccomment_count%2Ccan_comment%2Ccontent%2Ceditable_content%2Cvoteup_count%2Creshipment_settings%2Ccomment_permission%2Ccreated_time%2Cupdated_time%2Creview_info%2Crelevant_info%2Cquestion%2Cexcerpt%2Crelationship.is_authorized%2Cis_author%2Cvoting%2Cis_thanked%2Cis_nothelp%2Cis_labeled%2Cis_recognized%2Cpaid_info%2Cpaid_info_content%3Bdata%5B*%5D.mark_infos%5B*%5D.url%3Bdata%5B*%5D.author.follower_count%2Cbadge%5B*%5D.topics&" \
# "sort_by=default&platform=desktop" + "&offset=" + str(begin_index) + "&limit=10"
......@@ -642,7 +644,7 @@ if __name__ == '__main__':
gevent_spawn_obj_list = list()
for cur_index in range(0,50,1):
for cur_index in range(0,500,1):
g_obj = gevent.spawn(concurrence_dispose_query_word,account)
gevent_spawn_obj_list.append(g_obj)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment