-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathl_huoyunma.py
123 lines (111 loc) · 2.89 KB
/
l_huoyunma.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# -*- coding: UTF-8 -*-
import os
import urllib.request
from urllib import error
import time
import socket
socket.setdefaulttimeout(20)
# eventid = '43327'
# isLocalTest = True
# if isLocalTest:
# root = '/Users/lobo/Documents/Code/PhoneDecode' #根目录
# else:
# root = os.getcwd().replace('\\','/')#对Windows下的路径进行处理
# path = root+'/'+eventid
os.chdir('/Users/lobo/Documents/Code/PhoneSpider')
i=input("请输入获取数:")
j=1
try:
file=urllib.request.urlopen('http://47.94.137.238/api/do.php?action=loginIn&name=xiaoxiaolong668&password=z12345')
except error.HTTPError as e:
print (e.code)
except error.URLError as e:
print (e.reason)
data=file.readline()
idata=str(data, encoding = "utf-8")
print('toekenrs:',idata)
if idata[:1] == '1':
token=idata[2:]
print("token:"+token)
else:
print("获取token失败")
file.close()
while j<=int(i):
try:
file1=urllib.request.urlopen('http://47.94.137.238/api/do.php?action=getPhone&sid=998&token='+token)
except error.HTTPError as e:
print (e.code)
except error.URLError as e:
print (e.reason)
except:
pass
try:
data2=file1.readline()
iphone=str(data2, encoding = "utf-8")
except:
pass
print('phoners:',iphone)
file1.close()
if iphone[:1] == '1':
phone = iphone[2:13]
b = os.getcwd() + '/dataout/'
f1=open(b+phone+'.txt', "w")
f1.write(phone)
f1.close()
#a = os.path.dirname(os.getcwd()) + '\\phonenumber\\'
#f2=open(a+phone+'.txt', "w")
#f2.write(phone)
#f2.close()
try:
releaseUrl = 'http://47.94.137.238/api/do.php?action=cancelRecv&sid=998&phone='+phone+'&token='+token
file2=urllib.request.urlopen(releaseUrl)
except error.HTTPError as e:
print (e.code)
except error.URLError as e:
print (e.reason)
except:
pass
try:
data3=file2.readline()
ufile=str(data3,encoding = "utf-8")
except:
pass
print('releaseUrl:',releaseUrl)
print("releasers:",ufile)
file2.close()
if ufile[:1] == '0':
print('重新获取token...')
try:
rfile=urllib.request.urlopen('http://47.94.137.238/api/do.php?action=loginIn&name=xiaoxiaolong668&password=z12345')
except error.HTTPError as e:
print (e.code)
except error.URLError as e:
print (e.reason)
except:
pass
data=rfile.readline()
idata=str(data, encoding = "utf-8")
token=idata[2:]
rfile.close()
j=j+1
print("执行获取操作次数:"+str(j-1))
time.sleep(3)
def visitDir(path):
if not os.path.isdir(path):
print('Error: "', path, '" is not a directory or does not exist.')
return
else:
global x
try:
for lists in os.listdir(path):
#sub_path = os.path.join(path, lists)
x += 1
#print('No.', x, ' ', sub_path)
#if os.path.isdir(sub_path):
#visitDir(sub_path)
except:
pass
if __name__ == '__main__':
x = 0
visitDir(b)
print('获取号码总数: ', x)