Commit 3ba8795e authored by lixiaofang's avatar lixiaofang

add

parent c4ce62ac
......@@ -24,5 +24,29 @@
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
<DBN-PSQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
</code_scheme>
</component>
\ No newline at end of file
# -*- coding: UTF-8 -*-
import requests
import time
import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
from django.conf import settings
from get_session import get_comments, get_cookies, click, time_conv, login, reply
@shared_task
def auto_click(id):
try:
cookies = login()
if cookies is not None:
num1 = random.randint(0, 500)
time.sleep(num1)
click(cookies, id)
cookies = login()
if cookies is not None:
num2 = random.randint(1000, 2000)
time.sleep(num2)
click(cookies, id)
cookies = login()
if cookies is not None:
num3 = random.randint(2500, 4000)
time.sleep(num3)
click(cookies, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
@shared_task
def auto_reply(id):
try:
cookies = login()
if cookies:
time.sleep(random.randint(0, 500))
num1 = random.randint(0, 500)
time.sleep(num1)
comment_content = get_comments()
comment = comment_content[0]
reply(cookies, id, comment)
cookies = login()
if cookies:
num2 = random.randint(1000, 2000)
time.sleep(num2)
comment_content = get_comments()
comment = comment_content[0]
reply(cookies, id, comment)
cookies = login()
if cookies:
num3 = random.randint(2500, 4000)
time.sleep(num3)
comment_content = get_comments()
comment = comment_content[0]
reply(cookies, id, comment)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
# 发帖瞬时:[1 - 5]个马甲点赞
# 1. 用户发帖后,[瞬时],1-3条评论
import requests
import time
import datetime
import random
import traceback
# 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"
def get_majia():
try:
data = open("/srv/apps/cybertron/majia_email")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def login():
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
def click(cookies_get,id):
try:
post_dict = {
'type': 0,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def reply(cookies_get, id, content):
try:
post_dict = {
'topic_id': id,
'content': content
}
response = requests.post(url=auto_reply_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(minutest):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=minutest)
print(yes_time)
return yes_time
except:
return None
def get_comments():
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
This diff is collapsed.
import requests
import traceback
import logging
login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first():
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
logging.error("index_first:%s" % traceback.format_exc())
return None
def get_cook():
data = open("majia_email")
list = []
dicts = {}
for i in data:
list.append(i.strip('\n').strip(','))
for i in list:
cookies = index_first()
post_dict = {
'account_type': 2,
'pwd': '123456',
'email': i
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
headers = response.headers
print(response.text)
cook = headers['Set-Cookie'].split(";")
cook = cook[0].split('=')[1]
logging.info("response.text :%s" % response.text)
dicts[i] = cook
return dicts
dicts = get_cook()
with open("user_session.txt", 'w') as f:
for key, value in dicts.items():
f.write(key)
f.write(",")
f.write(value)
f.write("\n")
......@@ -11,7 +11,11 @@ class CeleryTaskRouter(object):
queue_task_map = {
"tapir-alpha": [
'injection.data_sync.tasks.write_to_es',
],
"majia-alpha": [
'injection.data_sync.auto_instant_click.auto_click',
]
}
# Map[TaskName, QueueName]
......
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