Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cybertron
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
alpha
cybertron
Commits
1ffd3535
Commit
1ffd3535
authored
Dec 08, 2018
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try except
parent
98283ef0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
412 additions
and
11 deletions
+412
-11
workspace.xml
.idea/workspace.xml
+0
-0
auto_pick.py
auto_pick.py
+6
-6
auto_star_pick.py
auto_star_pick.py
+245
-0
auto_star_urge.py
auto_star_urge.py
+154
-0
dd.py
dd.py
+7
-5
No files found.
.idea/workspace.xml
View file @
1ffd3535
This diff is collapsed.
Click to expand it.
auto_pick.py
View file @
1ffd3535
...
...
@@ -172,6 +172,7 @@ def get_new_user_id(numtime):
return
None
def
get_star_useid
(
numtime
):
try
:
db
=
pymysql
.
connect
(
host
=
"rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com"
,
user
=
'work'
,
passwd
=
'Gengmei123'
,
...
...
@@ -220,9 +221,9 @@ if __name__ == "__main__":
# time.sleep(random.randint(500, 1000))
#star
for
i
in
time_list
:
for
i
in
range
(
len
(
time_list
))
:
numtime
=
time_conv
(
i
)
numtime
=
time_conv
(
time_list
[
i
]
)
user_id
=
get_star_useid
(
numtime
)
...
...
@@ -242,17 +243,16 @@ if __name__ == "__main__":
# time.sleep(random.randint(500, 1000))
for
i
in
time_list
:
for
i
in
range
(
len
(
time_list
))
:
if
i
==
1
:
if
time_list
[
i
]
==
1
:
numtime
=
time_conv
(
1
)
numtime
=
time_conv
(
time_list
[
i
]
)
topic_user_id
=
get_data
(
numtime
)
new_user_id
=
get_new_user_id
(
numtime
)
for
i
in
new_user_id
:
for
j
in
topic_user_id
:
...
...
auto_star_pick.py
0 → 100644
View file @
1ffd3535
import
requests
import
time
import
datetime
import
pymysql
import
random
import
traceback
from
log_settings
import
*
import
logging
auto_pick_url
=
"http://earth.igengmei.com/api/v1/pick/do_pick"
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
login
():
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
logins
(
id
):
try
:
cookies
=
index_first
()
post_dict
=
{
'account_type'
:
2
,
'pwd'
:
'123456'
,
'email'
:
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
pick
(
cookies_get
,
id
):
try
:
post_dict
=
{
'pick_user_id'
:
id
,
'is_pick'
:
1
,
'pick_type'
:
0
}
response
=
requests
.
post
(
url
=
auto_pick_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_data
(
numtime
):
try
:
db
=
pymysql
.
connect
(
host
=
"rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com"
,
user
=
'work'
,
passwd
=
'Gengmei123'
,
db
=
"alpha"
,
port
=
3306
)
cursor
=
db
.
cursor
()
cursor
.
execute
(
"SELECT distinct(user_id) FROM topic WHERE create_time LIKE '
%%%%%
s
%%%%
'"
%
numtime
)
data
=
cursor
.
fetchall
()
user_id
=
list
(
data
)
logging
.
info
(
"Database version :
%
s "
%
user_id
)
db
.
close
()
return
user_id
except
:
logging
.
error
(
"catch exception,get_data:
%
s"
%
traceback
.
format_exc
())
return
None
def
get_new_user_id
(
numtime
):
try
:
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 account_user WHERE is_online =1 and create_time LIKE '
%%%%%
s
%%%%
'"
%
numtime
)
data_new_user
=
cursor
.
fetchall
()
data
=
list
(
data_new_user
)
logging
.
info
(
"Database version :
%
s "
%
data
)
db
.
close
()
return
user_id
except
:
logging
.
error
(
"catch exception,get_data:
%
s"
%
traceback
.
format_exc
())
return
None
def
get_star_useid
(
numtime
):
try
:
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 topic WHERE is_online =1 and content_level =4 or content_level =5 and create_time LIKE '
%%%%%
s
%%%%
'"
%
numtime
)
data
=
cursor
.
fetchall
()
user_id
=
list
(
data
)
logging
.
info
(
"Database version :
%
s "
%
user_id
)
db
.
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
]
#star
for
i
in
range
(
len
(
time_list
)):
numtime
=
time_conv
(
time_list
[
i
])
user_id
=
get_star_useid
(
numtime
)
for
j
in
user_id
:
id
=
int
(
j
[
0
])
# time.sleep(random.randint(200,500))
pick_num
=
random
.
randint
(
1
,
5
)
for
i
in
range
(
pick_num
):
cookies
=
login
()
pick
(
cookies
,
id
)
# time.sleep(random.randint(500, 1000))
for
i
in
range
(
len
(
time_list
)):
if
time_list
[
i
]
==
1
:
numtime
=
time_conv
(
time_list
[
i
])
topic_user_id
=
get_data
(
numtime
)
new_user_id
=
get_new_user_id
(
numtime
)
for
i
in
new_user_id
:
for
j
in
topic_user_id
:
if
i
==
j
:
pick_num
=
random
.
randint
(
0
,
1
)
for
x
in
range
(
pick_num
):
cookies
=
logins
(
id
)
pick
(
cookies
,
i
)
except
:
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
auto_star_urge.py
0 → 100644
View file @
1ffd3535
import
requests
import
time
import
datetime
import
pymysql
import
random
import
pandas
as
pd
import
traceback
from
log_settings
import
*
import
logging
auto_urge_url
=
"http://earth.igengmei.com/api/v1/user/urge"
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
Urge
(
cookies_get
,
id
):
try
:
post_dict
=
{
'id'
:
id
}
response
=
requests
.
post
(
url
=
auto_urge_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_star_useid
(
numtime
):
try
:
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 topic WHERE is_online=1 and content_level =4 or content_level =5 and create_time LIKE '
%%%%%
s
%%%%
'"
%
numtime
)
data
=
cursor
.
fetchall
()
user_id
=
list
(
data
)
logging
.
info
(
"Database version :
%
s "
%
user_id
)
db
.
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
])
# time.sleep(random.randint(200,500))
for
i
in
range
(
1
):
cookies
=
logins
()
Urge
(
cookies
,
id
)
# time.sleep(random.randint(500, 1000))
except
:
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
\ No newline at end of file
dd.py
View file @
1ffd3535
x
=
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
695
,),
(
696
,),
(
695
,),
(
698
,),
(
699
,),
(
700
,),
(
695
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
709
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
678
,),
(
None
,),
(
709
,),
(
709
,),
(
709
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
732
,),
(
730
,),
(
729
,),
(
None
,),
(
173
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,),
(
None
,)
for
i
in
range
(
3
):
print
(
i
)
for
i
in
x
:
for
i
in
range
(
3
):
print
(
i
)
if
i
[
0
]
is
not
None
:
print
(
i
[
0
])
\ No newline at end of file
for
i
in
range
(
3
):
print
(
i
)
\ No newline at end of file
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