1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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 login, time_conv, Urge
from auto_request import host, user, port, db, passwd
def get_star_useid(numtime):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor()
cursor.execute(
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time LIKE '%%%%%s%%%%' 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_conv(i)
user_id = get_star_useid(numtime)
for j in user_id:
id = int(j[0])
for i in range(1):
time.sleep(random.randint(10, 50))
cookies = login()
if cookies is not None:
Urge(cookies, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())