Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
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
alpha
physical
Commits
13c6e56e
Commit
13c6e56e
authored
Oct 12, 2019
by
吴升宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add auto follow per 2h
parent
3ead6d7b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
29 deletions
+89
-29
trans2es_mapping2es.py
trans2es/management/commands/trans2es_mapping2es.py
+4
-1
auto_follow_per_2h_by_post_and_regist.py
vest/follow/auto_follow_per_2h_by_post_and_regist.py
+73
-0
auto_request.py
vest/request/auto_request.py
+1
-2
test.py
vest/test.py
+11
-26
tt.py
vest/tt.py
+0
-0
No files found.
trans2es/management/commands/trans2es_mapping2es.py
View file @
13c6e56e
...
@@ -10,7 +10,8 @@ from trans2es.type_info import get_type_info_map, TypeInfo
...
@@ -10,7 +10,8 @@ from trans2es.type_info import get_type_info_map, TypeInfo
from
vest.reply
import
true_comment_one
,
true_comment_two
,
true_comment_three
,
one_seven_topic_comment
from
vest.reply
import
true_comment_one
,
true_comment_two
,
true_comment_three
,
one_seven_topic_comment
from
vest.click
import
true_click_five
,
true_click_two
,
true_click_four
,
true_click_one
,
true_click_three
,
\
from
vest.click
import
true_click_five
,
true_click_two
,
true_click_four
,
true_click_one
,
true_click_three
,
\
one_seven_star_topic
one_seven_star_topic
from
vest.follow
import
auto_follow
,
auto_follow_new
,
auto_follow_per_5m_by_followed
,
auto_follow_per_1d_by_regist
,
auto_follow_per_1d_by_post
from
vest.follow
import
auto_follow
,
auto_follow_new
,
auto_follow_per_5m_by_followed
,
\
auto_follow_per_1d_by_regist
,
auto_follow_per_1d_by_post
,
auto_follow_per_2h_by_post_and_regist
from
vest.urge
import
auto_star_urge
,
auto_lunch_app
,
auto_lunch_app2
,
auto_urge1
,
auto_urge2
from
vest.urge
import
auto_star_urge
,
auto_lunch_app
,
auto_lunch_app2
,
auto_urge1
,
auto_urge2
from
vest.fix
import
fix_no_comment_click
from
vest.fix
import
fix_no_comment_click
from
vest.reply_answer
import
reply_comment2
,
reply_comment3
,
answer_reply2
,
answer_reply3
,
answer_reply1
,
\
from
vest.reply_answer
import
reply_comment2
,
reply_comment3
,
answer_reply2
,
answer_reply3
,
answer_reply1
,
\
...
@@ -120,6 +121,8 @@ class Command(BaseCommand):
...
@@ -120,6 +121,8 @@ class Command(BaseCommand):
auto_follow_per_1d_by_regist
.
auto_follow_per_1d_by_regist
()
auto_follow_per_1d_by_regist
.
auto_follow_per_1d_by_regist
()
if
options
[
'mvest'
]
==
"auto_follow_per_1d_by_post"
:
if
options
[
'mvest'
]
==
"auto_follow_per_1d_by_post"
:
auto_follow_per_1d_by_post
.
auto_follow_per_1d_by_post
()
auto_follow_per_1d_by_post
.
auto_follow_per_1d_by_post
()
if
options
[
'mvest'
]
==
"auto_follow_per_2h_by_post_and_regist"
:
auto_follow_per_2h_by_post_and_regist
.
auto_follow_per_2h_by_post_and_regist
()
# 补足
# 补足
if
options
[
"mvest"
]
==
"fix_no_comment_click"
:
if
options
[
"mvest"
]
==
"fix_no_comment_click"
:
...
...
vest/follow/auto_follow_per_2h_by_post_and_regist.py
0 → 100644
View file @
13c6e56e
import
pymysql
import
random
import
traceback
import
logging
from
threading
import
Thread
from
vest.request.auto_request
import
login
,
time_conv_hour
,
follow
from
vest.request.auto_request
import
host
,
user
,
db
,
passwd
from
libs.error
import
logging_exception
def
get_commnet_id
(
numtime
,
numtime2
,
content_level_low
=
0
,
content_level_top
=
6
):
pc
=
pymysql
.
connect
(
host
=
host
,
user
=
user
,
passwd
=
passwd
,
db
=
db
,
port
=
3306
)
cursor
=
pc
.
cursor
()
# 发贴后
cursor
.
execute
(
"select t.user_id from topic t left join user_extra u on t.user_id = u.user_id "
"where u.is_shadow=0 and t.create_time > '
%
s' and t.create_time < '
%
s' "
"and t.content_level >=
%
s and t.content_level <=
%
s "
%
(
numtime
,
numtime2
,
str
(
content_level_low
),
str
(
content_level_top
)))
res_post
=
cursor
.
fetchall
()
# 注册后
cursor
.
execute
(
"select a.user_id from account_user a left join user_extra u on a.user_id = u.user_id "
"WHERE a.create_time > '
%
s' and a.create_time < '
%
s' and u.is_shadow = 0 "
%
(
numtime
,
numtime2
))
res_regist
=
cursor
.
fetchall
()
res
=
[]
res
.
extend
(
res_regist
)
res
.
extend
(
res_post
)
return
res
and
[
i
for
i
,
in
res
]
or
[]
def
batch_handle
(
auto_follow_list
):
for
user_id
in
auto_follow_list
:
try
:
cookies
=
login
()
if
cookies
is
not
None
:
follow
(
cookies
,
user_id
)
except
:
pass
def
auto_follow_per_2h_by_post_and_regist
():
# 发帖,注册触发自动加粉丝
auto_follow_list
=
[]
try
:
# 发帖,注册后2小时内:[1-3]个粉丝
numtime1
,
numtime2
=
time_conv_hour
(
0
,
2
)
user_ids
=
get_commnet_id
(
numtime2
,
numtime1
,
content_level_low
=
0
,
content_level_top
=
6
)
for
user_id
in
user_ids
:
follow_num
=
random
.
randint
(
1
,
3
)
for
i
in
range
(
follow_num
):
auto_follow_list
.
append
(
user_id
)
except
:
logging_exception
()
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
logging
.
info
(
'auto_follow_per_2h_by_post_and_regist: len
%
s'
%
len
(
auto_follow_list
))
print
(
'auto_follow_per_2h_by_post_and_regist: len
%
s'
%
len
(
auto_follow_list
))
total
=
len
(
auto_follow_list
)
limit
=
(
total
+
10
)
//
10
for
start
in
range
(
0
,
total
,
limit
):
batch
=
auto_follow_list
[
start
:
start
+
limit
]
t
=
Thread
(
target
=
batch_handle
,
args
=
[
batch
])
t
.
start
()
vest/request/auto_request.py
View file @
13c6e56e
...
@@ -173,10 +173,9 @@ def time_conv_minute(minutest, minutest2):
...
@@ -173,10 +173,9 @@ def time_conv_minute(minutest, minutest2):
def
time_conv_hour
(
minutest
,
minutest2
):
def
time_conv_hour
(
minutest
,
minutest2
):
try
:
try
:
now
=
datetime
.
datetime
.
now
()
now
=
datetime
.
datetime
.
now
()
minute
=
datetime
.
datetime
.
now
()
.
minute
yes_time
=
now
-
datetime
.
timedelta
(
hours
=
minutest
)
yes_time
=
now
-
datetime
.
timedelta
(
hours
=
minutest
)
yes_time2
=
now
-
datetime
.
timedelta
(
hours
=
minutest2
)
yes_time2
=
now
-
datetime
.
timedelta
(
hours
=
minutest2
)
return
yes_time
,
yes_time2
,
minute
return
yes_time
,
yes_time2
except
:
except
:
return
None
return
None
...
...
vest/test.py
View file @
13c6e56e
...
@@ -119,30 +119,15 @@ def get_commnet_id(numtime, numtime2):
...
@@ -119,30 +119,15 @@ def get_commnet_id(numtime, numtime2):
def
time_conv_hour
(
minutest
,
minutest2
):
try
:
now
=
datetime
.
datetime
.
now
()
yes_time
=
now
-
datetime
.
timedelta
(
hours
=
minutest
)
yes_time2
=
now
-
datetime
.
timedelta
(
hours
=
minutest2
)
return
yes_time
,
yes_time2
except
:
return
None
import
asyncio
a
,
b
=
time_conv_hour
(
0
,
2
)
import
time
async
def
say_after
(
delay
):
await
asyncio
.
sleep
(
delay
)
print
(
delay
)
return
delay
async
def
main
():
task_list
=
[]
for
i
in
range
(
10
):
task_list
.
append
(
asyncio
.
create_task
(
say_after
(
i
)))
for
i
in
task_list
:
await
i
# task1 = asyncio.create_task(say_after(2, 'hello2'))
print
(
a
,
b
)
# task2 = asyncio.create_task(say_after(1, 'world2'))
\ No newline at end of file
# result3 = await task1
# result4 = await task2
# print(result3, result4)
# print(f"finished at {time.strftime('%X')}")
# 通过asyncio.run()函数运行
asyncio
.
run
(
main
())
\ No newline at end of file
vest/tt.py
deleted
100644 → 0
View file @
3ead6d7b
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