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
钟尚武
physical
Commits
757ba7f5
Commit
757ba7f5
authored
Apr 24, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
0db2fe2e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
88 deletions
+91
-88
tasks.py
majia/tasks.py
+91
-88
No files found.
majia/tasks.py
View file @
757ba7f5
...
@@ -8,103 +8,106 @@ import logging
...
@@ -8,103 +8,106 @@ import logging
from
celery
import
shared_task
from
celery
import
shared_task
from
django.conf
import
settings
from
django.conf
import
settings
from
majia.get_session
import
get_comments
,
click
,
login
,
reply
from
majia.get_session
import
get_comments
,
click
,
login
,
reply
from
majia.get_session
import
host
,
user
,
passwd
,
db
#
from majia.get_session import host, user, passwd, db
exec_count
=
0
exec_count
=
0
def
auto_click
(
pk_list
):
def
auto_click
(
pk_list
):
exec_count
=
0
logging
.
info
(
"get----------------------:
%
s"
%
pk_list
)
try
:
# exec_count = 0
pc
=
pymysql
.
connect
(
host
=
host
,
user
=
user
,
passwd
=
passwd
,
db
=
db
,
port
=
3306
)
# try:
cursor
=
pc
.
cursor
()
# pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor
.
execute
(
# cursor = pc.cursor()
"SELECT id,user_id FROM topic WHERE id in "
+
str
(
# cursor.execute(
tuple
(
pk_list
))
+
" and user_id in (select user_id from user_extra where is_shadow = 0)"
)
# "SELECT id,user_id FROM topic WHERE id in " + str(
data
=
cursor
.
fetchall
()
# tuple(pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
topic_id_list
=
list
(
data
)
# data = cursor.fetchall()
logging
.
info
(
"Database version :
%
s "
%
topic_id_list
)
# topic_id_list = list(data)
pc
.
close
()
# logging.info("Database version : %s " % topic_id_list)
exec_count
=
0
# pc.close()
if
topic_id_list
:
# exec_count = 0
# if topic_id_list:
def
fun_timer
():
#
cookies
=
login
()
# def fun_timer():
if
cookies
:
# cookies = login()
click
(
cookies
,
topic_id_list
[
0
])
# if cookies:
# click(cookies, topic_id_list[0])
global
timer
#
global
exec_count
# global timer
# global exec_count
exec_count
+=
1
#
if
exec_count
==
1
:
# exec_count += 1
# sleep_time = random.randint(300, 540)
# if exec_count == 1:
sleep_time
=
30
# # sleep_time = random.randint(300, 540)
timer
=
threading
.
Timer
(
sleep_time
,
fun_timer
)
# sleep_time = 30
timer
.
start
()
# timer = threading.Timer(sleep_time, fun_timer)
# timer.start()
if
exec_count
==
2
:
#
# sleep_time = random.randint(1000, 1900)
# if exec_count == 2:
sleep_time
=
50
# # sleep_time = random.randint(1000, 1900)
timer
=
threading
.
Timer
(
sleep_time
,
fun_timer
)
# sleep_time = 50
timer
.
start
()
# timer = threading.Timer(sleep_time, fun_timer)
# timer.start()
sleep_time
=
random
.
randint
(
300
,
540
)
#
timer
=
threading
.
Timer
(
10
,
fun_timer
)
# 首次启动
# sleep_time = random.randint(300, 540)
timer
.
start
()
# timer = threading.Timer(10, fun_timer) # 首次启动
# timer.start()
else
:
#
pass
# else:
except
:
# pass
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
# except:
# logging.error("catch exception,main:%s" % traceback.format_exc())
def
auto_reply
(
pk_list
):
def
auto_reply
(
pk_list
):
exec_count
=
0
logging
.
info
(
"get----------------------:
%
s"
%
pk_list
)
try
:
pc
=
pymysql
.
connect
(
host
=
host
,
user
=
user
,
passwd
=
passwd
,
db
=
db
,
port
=
3306
)
# exec_count = 0
cursor
=
pc
.
cursor
()
# try:
cursor
.
execute
(
# pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
"SELECT id,user_id FROM topic WHERE id in "
+
str
(
# cursor = pc.cursor()
tuple
(
pk_list
))
+
" and user_id in (select user_id from user_extra where is_shadow = 0)"
)
# cursor.execute(
data
=
cursor
.
fetchall
()
# "SELECT id,user_id FROM topic WHERE id in " + str(
topic_id_list
=
list
(
data
)
# tuple(pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
logging
.
info
(
"Database version :
%
s "
%
topic_id_list
)
# data = cursor.fetchall()
pc
.
close
()
# topic_id_list = list(data)
exec_count
=
0
# logging.info("Database version : %s " % topic_id_list)
if
topic_id_list
:
# pc.close()
# exec_count = 0
def
fun_comment
():
# if topic_id_list:
cookies
=
login
()
#
if
cookies
:
# def fun_comment():
comment_content
=
get_comments
()
# cookies = login()
comment
=
comment_content
[
0
]
# if cookies:
reply
(
cookies
,
topic_id_list
[
0
],
comment
)
# comment_content = get_comments()
# comment = comment_content[0]
global
timer
# reply(cookies, topic_id_list[0], comment)
global
exec_count
#
# global timer
exec_count
+=
1
# global exec_count
if
exec_count
==
1
:
#
sleep_time
=
random
.
randint
(
300
,
540
)
# exec_count += 1
sleep_time
=
30
# if exec_count == 1:
timer
=
threading
.
Timer
(
sleep_time
,
fun_comment
)
# sleep_time = random.randint(300, 540)
timer
.
start
()
# sleep_time = 30
# timer = threading.Timer(sleep_time, fun_comment)
if
exec_count
==
2
:
# timer.start()
sleep_time
=
random
.
randint
(
1000
,
1900
)
#
sleep_time
=
30
# if exec_count == 2:
timer
=
threading
.
Timer
(
sleep_time
,
fun_comment
)
# sleep_time = random.randint(1000, 1900)
timer
.
start
()
# sleep_time = 30
# timer = threading.Timer(sleep_time, fun_comment)
sleep_time
=
random
.
randint
(
300
,
540
)
# timer.start()
timer
=
threading
.
Timer
(
10
,
fun_comment
)
# 首次启动
#
timer
.
start
()
# sleep_time = random.randint(300, 540)
# timer = threading.Timer(10, fun_comment) # 首次启动
# timer.start()
except
:
#
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
#
# except:
# logging.error("catch exception,main:%s" % traceback.format_exc())
@shared_task
@shared_task
...
...
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