Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
strategy_spider
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rank
strategy_spider
Commits
999f94f2
Commit
999f94f2
authored
Jan 30, 2020
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增大并发
parent
26c05f94
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
zhihu_login.py
zhihu_login.py
+7
-5
No files found.
zhihu_login.py
View file @
999f94f2
...
@@ -40,7 +40,8 @@ from gevent import monkey; monkey.patch_socket()
...
@@ -40,7 +40,8 @@ from gevent import monkey; monkey.patch_socket()
import
gevent
import
gevent
from
threading
import
Thread
,
Lock
from
threading
import
Thread
,
Lock
import
urllib.parse
import
urllib.parse
import
hashlib
import
random
mutex_for_get_query_word
=
Lock
()
mutex_for_get_query_word
=
Lock
()
...
@@ -365,11 +366,12 @@ class ZhihuAccount(object):
...
@@ -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
):
def
zhihu_query_by_word
(
self
,
query_word
,
zhihu_spider_fd
,
zhihu_spider_question_fd
,
question_answer_dict
,
cur_word_index
):
try
:
try
:
cur_image_index
=
0
cur_image_index
=
0
for
begin_index
in
range
(
0
,
10
0
,
10
):
for
begin_index
in
range
(
0
,
5
0
,
10
):
# query_by_word_url = "https://www.zhihu.com/api/v4/search_v3?t=general&correction=1&lc_idx=62&" \
# 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&" \
# "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"
# "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_by_word_url
=
"https://www.zhihu.com/api/v4/search_v3?"
query_params_dict
=
{
query_params_dict
=
{
"q"
:
query_word
,
"q"
:
query_word
,
...
@@ -377,7 +379,7 @@ class ZhihuAccount(object):
...
@@ -377,7 +379,7 @@ class ZhihuAccount(object):
"limit"
:
10
,
"limit"
:
10
,
"lc_idx"
:
22
,
"lc_idx"
:
22
,
"show_all_topics"
:
0
,
"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"
,
"vertical_info"
:
"0,0,0,0,0,0,0,0,0,1"
,
"correction"
:
1
,
"correction"
:
1
,
"t"
:
"general"
"t"
:
"general"
...
@@ -479,7 +481,7 @@ class ZhihuAccount(object):
...
@@ -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
):
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
,
10
0
,
10
):
for
begin_index
in
range
(
0
,
2
0
,
10
):
# answers_list_by_question_url = "https://www.zhihu.com/api/v4/questions/" + str(question_id) + \
# 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&" \
# "/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"
# "sort_by=default&platform=desktop" + "&offset=" + str(begin_index) + "&limit=10"
...
@@ -642,7 +644,7 @@ if __name__ == '__main__':
...
@@ -642,7 +644,7 @@ if __name__ == '__main__':
gevent_spawn_obj_list
=
list
()
gevent_spawn_obj_list
=
list
()
for
cur_index
in
range
(
0
,
50
,
1
):
for
cur_index
in
range
(
0
,
50
0
,
1
):
g_obj
=
gevent
.
spawn
(
concurrence_dispose_query_word
,
account
)
g_obj
=
gevent
.
spawn
(
concurrence_dispose_query_word
,
account
)
gevent_spawn_obj_list
.
append
(
g_obj
)
gevent_spawn_obj_list
.
append
(
g_obj
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment