Commit 6050947b authored by lixiaofang's avatar lixiaofang

add

parent 77f4e958
This diff is collapsed.
......@@ -7,7 +7,7 @@ import pandas as pd
import traceback
from log_settings import *
import logging
from auto_request import login, reply, click, get_comment, time_conv
from auto_request import login, reply, click, get_comments, time_conv
from auto_request import host, user, port, db, passwd
......@@ -127,6 +127,7 @@ from auto_request import host, user, port, db, passwd
# except:
#
# return None
# 9,12,18,2
def get_topic_id(numtime):
......@@ -156,11 +157,14 @@ if __name__ == "__main__":
click_num = random.randint(1, 3)
for i in range(click_num):
for j in topic_id:
id = int(j[0])
cookies = login()
time.sleep(random.randint(1, 10))
time.sleep(random.randint(10, 20))
click(cookies, id)
......@@ -168,7 +172,9 @@ if __name__ == "__main__":
topic_id = get_topic_id(numtime)
comment_num = random.randint(1, 3)
comment_num = random.randint(0, 3)
comment_content = get_comments()
for i in range(comment_num):
......@@ -179,8 +185,10 @@ if __name__ == "__main__":
cookies = login()
if cookies is not None:
comment = get_comment()
time.sleep(random.randint(1, 10))
comment = comment_content[i]
time.sleep(random.randint(10,20))
reply(cookies, id, comment)
......
......@@ -131,7 +131,9 @@ if __name__ == "__main__":
else:
dicts[i[0]].append(i[1])
print(dicts)
for key, value in dicts.items():
rand_num = random.randint(0, len(value) - 1)
......
......@@ -151,6 +151,7 @@ if __name__ == "__main__":
cook = login()
if cook is not None:
click(cook, rand_id)
except:
......
......@@ -134,33 +134,17 @@ if __name__ == "__main__":
topic_id = get_topic_id(numtime)
dicts = {}
comment = get_comment()
for i in topic_id:
if i[0] not in dicts.keys():
dicts.setdefault(i[0], [])
dicts[i[0]].append(i[1])
else:
dicts[i[0]].append(i[1])
for key, value in dicts.items():
rand_num = random.randint(0, len(value) - 1)
rand_id = value[rand_num]
for id in topic_id:
time.sleep(random.randint(1, 10))
cook = login()
if cook is not None:
comment = get_comment()
reply(cook, rand_id, comment)
reply(cook, id, comment)
except:
......
......@@ -29,10 +29,11 @@ auto_urge_url = "http://earth.igengmei.com/api/v1/user/urge"
# port = 3306
host = "rm-2zeaut61u9sm21m0b.mysql.rds.aliyuncs.com"
user = 'work'
passwd = 'Gengmei123'
user = "work"
passwd = "Gengmei123"
db = "alpha"
port = '3306'
port ="3306"
def get_majia():
try:
......@@ -147,7 +148,9 @@ def get_comment():
list_guanshui = []
for i in data:
list_guanshui.append(i)
num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
return comment
......@@ -157,6 +160,32 @@ def get_comment():
return None
def get_comments():
try:
data = open("/srv/apps/cybertron/guanshui", "r")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num1 = random.randint(0, 50)
num2 = random.randint(50, 70)
num3 = random.randint(70, len(list_guanshui))
comment1 = list_guanshui[num1 - 1]
comment2 = list_guanshui[num2 - 1]
comment3 = list_guanshui[num3 - 1]
comment_list = [comment1,comment2,comment3]
return comment_list
except:
return None
def follow(cookies_get, id):
try:
post_dict = {
......@@ -188,3 +217,43 @@ def Urge(cookies_get, id):
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def get_offline_comment():
try:
data = open("/srv/apps/cybertron/offline_comment.txt", "r")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num1 = random.randint(0, 500)
num2 = random.randint(500, 1000)
num3 = random.randint(1000, 1500)
num4 = random.randint(1500, len(list_guanshui))
comment1 = list_guanshui[num1 - 1]
comment2 = list_guanshui[num2 - 1]
comment3 = list_guanshui[num3 - 1]
comment4 = list_guanshui[num4 - 1]
comment_list = [comment1, comment2, comment3, comment4]
return comment_list
except:
return None
def logins():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
import requests
import time
import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
from auto_request import host, user, port, db, passwd
def get_data():
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
cursor.execute("select user_id from user_extra where is_shadow = 0")
data = cursor.fetchall()
user_id = list(data)
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
data = get_data(time)
file = open("user_id.txt")
for i in data:
file.write(i)
import requests
import time
import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
from auto_request import logins, reply, get_offline_comment, time_convs
# from auto_request import host, user, port, db, passwd
auto_click_url = "http://earth.igengmei.com/api/v1/like"
auto_reply_url = "http://earth.igengmei.com/api/v1/reply/create"
auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
auto_urge_url = "http://earth.igengmei.com/api/v1/user/urge"
# 对所有马甲生产的帖子(包含历史帖子)
#
# 离线一次性插入{0,4}条评论
#
# 评论取自评论库,并自动随机关联马甲
#
# 注意需要禁止本帖作者评论
host = "rm-2zeaut61u9sm21m0b.mysql.rds.aliyuncs.com"
user = "work"
passwd = "Gengmei123"
db = "alpha"
port ="3306"
def get_data(numtime):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
cursor.execute(
"SELECT id FROM topic WHERE is_online =1 and create_time >= %s and (content_level = 4 or content_level = 5) and user_id in (select user_id from user_extra where is_shadow = 0)",
(numtime))
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
time_list = [1, 2, 3, 4, 5, 6, 7]
for i in time_list:
numtime = time_convs(i)
topic_id = get_data(numtime)
dicts = {}
rand_num = random.randint(0, 4)
for id in topic_id:
comment_list = get_offline_comment()
for i in rand_num:
cook =logins()
comment = get_offline_comment()
comment = comment_list[rand_num]
reply(cook, id, comment)
except:
logging.error("catch exception,main :%s" % traceback.format_exc())
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