Commit c4d39acd authored by lixiaofang's avatar lixiaofang

try except

parent 03a9ceb6
......@@ -2,8 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="fd1f0b61-1139-44e5-87e7-f8b86ff52376" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/auto_click.py" beforeDir="false" afterPath="$PROJECT_DIR$/auto_click.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/auto_follow.py" beforeDir="false" afterPath="$PROJECT_DIR$/auto_follow.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/exe.py" beforeDir="false" afterPath="$PROJECT_DIR$/exe.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
......@@ -86,7 +86,7 @@
<entry key="cuigeng" value="1" />
<entry key="data" value="12" />
<entry key="dummy" value="15" />
<entry key="py" value="7494" />
<entry key="py" value="7521" />
<entry key="unr_data" value="1" />
<entry key="xuqiu" value="1" />
</counts>
......@@ -94,7 +94,7 @@
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="PLAIN_TEXT" value="161" />
<entry key="Python" value="7494" />
<entry key="Python" value="7521" />
</counts>
</usages-collector>
</session>
......@@ -216,11 +216,11 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/auto_follow.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="203" column="33" selection-start-line="203" selection-start-column="33" selection-end-line="203" selection-end-column="33" />
<state relative-caret-position="246">
<caret line="175" selection-start-line="175" selection-end-line="181" selection-end-column="49" />
<folding>
<element signature="e#0#15#0" expanded="true" />
<element signature="e#279#456#0" />
......@@ -233,11 +233,11 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/exe.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="8" lean-forward="true" selection-start-line="6" selection-start-column="8" selection-end-line="6" selection-end-column="8" />
<state relative-caret-position="105">
<caret line="7" column="14" selection-start-line="7" selection-start-column="14" selection-end-line="7" selection-end-column="14" />
</state>
</provider>
</entry>
......@@ -306,14 +306,14 @@
<option value="$PROJECT_DIR$/auto_star_topic.py" />
<option value="$PROJECT_DIR$/auto_urge.py" />
<option value="$PROJECT_DIR$/auto_click.py" />
<option value="$PROJECT_DIR$/exe.py" />
<option value="$PROJECT_DIR$/auto_follow.py" />
<option value="$PROJECT_DIR$/exe.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="x" value="931" />
<option name="y" value="148" />
<component name="ProjectFrameBounds" extendedState="1">
<option name="x" value="43" />
<option name="y" value="55" />
<option name="width" value="1705" />
<option name="height" value="727" />
</component>
......@@ -471,7 +471,7 @@
<servers />
</component>
<component name="ToolWindowManager">
<frame x="931" y="148" width="1705" height="727" extended-state="0" />
<frame x="43" y="55" width="1705" height="727" extended-state="1" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.20665084" />
......@@ -479,13 +479,13 @@
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32921174" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.0" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32913387" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.392126" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Version Control" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Terminal" order="8" weight="0.10393701" />
<window_info anchor="bottom" id="Terminal" order="8" weight="0.14173229" />
<window_info anchor="bottom" id="Event Log" order="9" side_tool="true" />
<window_info anchor="bottom" id="Python Console" order="10" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
......@@ -795,17 +795,10 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/exe.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="8" lean-forward="true" selection-start-line="6" selection-start-column="8" selection-end-line="6" selection-end-column="8" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/auto_follow.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="203" column="33" selection-start-line="203" selection-start-column="33" selection-end-line="203" selection-end-column="33" />
<state relative-caret-position="246">
<caret line="175" selection-start-line="175" selection-end-line="181" selection-end-column="49" />
<folding>
<element signature="e#0#15#0" expanded="true" />
<element signature="e#279#456#0" />
......@@ -817,5 +810,12 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/exe.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="7" column="14" selection-start-line="7" selection-start-column="14" selection-end-line="7" selection-end-column="14" />
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
......@@ -175,11 +175,11 @@ if __name__ == "__main__":
time_list = [1,2,3,4,5,6,7,11]
for i in time_list:
for i in range(len(time_list)):
if time_list[i] != 11:
numtime = time_conv(i)
numtime = time_conv(time_list[i])
user_id = get_data(numtime)
......@@ -199,26 +199,6 @@ if __name__ == "__main__":
# time.sleep(random.randint(2000,2500))
numtime = time_conv(1)
user_id = get_commnet_id(numtime)
for j in user_id:
id = int(j[0])
follow_num = random.randint(0,1)
# time.sleep(random.randint(500, 1500))
for i in range(follow_num):
cookies = logins()
follow(cookies, id)
# time.sleep(random.randint(2000, 3000))
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
import requests
import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.igengmei.com/api/v1/follow"
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_majia():
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
# time.sleep(random.randint(0, 500))
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 logins():
try:
# time.sleep(random.randint(300, 500))
user_id=get_majia()
cookies = index_first()
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
headers=response.headers
cook = headers['Set-Cookie'].split(";")
cook = cook[0].split('=')[1]
logging.info("response.text :%s"%response.text)
return {'sessionid': cook}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_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(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_commnet_id(numtime):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute(
"SELECT user_id FROM reply WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data_comment = cursor.fetchall()
cursor.execute(
"SELECT replied_id FROM reply WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data_reply = cursor.fetchall()
cursor.execute(
"SELECT user_id FROM group_user_role WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data_group_follow = cursor.fetchall()
cursor.execute(
"select user_id from account_user WHERE create_time LIKE '%%%%%s%%%%'" % numtime)
data_new_user = cursor.fetchall()
data_id = list(data_comment)
data1_id=list(data_reply)
data2_id=list(data_group_follow)
data3_id=list(data_new_user)
user_id = []
for i in data_id:
user_id.append(i)
for i in data1_id:
user_id.append(i)
for i in data2_id:
user_id.append(i)
for i in data3_id:
user_id.append(i)
print("Database version : %s " % user_id)
db.close()
return user_id
if __name__ == "__main__":
try:
numtime = time_conv(1)
user_id = get_commnet_id(numtime)
for j in user_id:
id = int(j[0])
follow_num = random.randint(0, 1)
# time.sleep(random.randint(500, 1500))
for i in range(follow_num):
cookies = logins()
follow(cookies, id)
# time.sleep(random.randint(2000, 3000))
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
time_list = [1, 11]
for i in range(len(time_list)):
if time_list[i] != 11:
print(time_list[i])
\ No newline at end of file
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