-
Notifications
You must be signed in to change notification settings - Fork 0
/
stepik.py
215 lines (193 loc) · 5.41 KB
/
stepik.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
###1
# a=[int(i) for i in input().split()]
# b=int(input())
# d=[]
# if b in a:
# for i in enumerate(a):
# if i[1] == b:
# d += [i[0]]
# for val in d:
# print(val, end=' ')
# else:
# print('Отсутствует')
###2
# n=int(input())
# m=int()
# for i in range(n*n):
###3
# def f(x):
# if x<=-2:
# m=1-(x+2)**2
# elif -2<x<=2:
# m=-x/2
# elif x>2:
# m=((x-2)**2)+1
# return m
###4
# lst = [1, 2, 3, 4, 5, 6]
# def modify_list(l):
# for i in range(len(l)):
# if l[i]%2:
# list[:]=l[i]/2
# else:
# i+=1
# return m
#
# modify_list(lst)
# print(lst)
# print(modify_list(lst)) # None
# print(lst) # [1, 2, 3]
# modify_list(lst)
# print(lst) # [1]
#
# lst = [10, 5, 8, 3]
# modify_list(lst)
# print(lst) # [5, 4]
###5
# def update_dictionary(d, key, value):
# if key in d:
# d[key].append(value)
# elif 2*key in d:
# d[2*key].append(value)
# else:
# d[2*key]=[]
# d[2*key].append(value)
#
# d = {}
# print(update_dictionary(d, 1, -1)) # None
# print(d) # {2: [-1]}
# update_dictionary(d, 2, -2)
# print(d) # {2: [-1, -2]}
# update_dictionary(d, 1, -3)
# print(d) # {2: [-1, -2, -3]}
###6
# list = input().lower().split()
# unique = []
# for i in set(list):
# print("{} {}".format(i, list.count(i)))
###7
# digits = set('0123456789')
# i = 0
# multiplier = ''
# decrypted = ''
#
# with open('dataset_3363_2 (3).txt') as in_f_obj:
# string = in_f_obj.readline().strip()
#
# char = string[i]
# i += 1
#
# while i < len(string):
#
# while string[i] in digits:
# multiplier += string[i]
# i += 1
# if i > (len(string) - 1):
# break
#
# # print(char * int(multiplier), end='')
# decrypted += (char * int(multiplier))
#
# multiplier = ''
# if i > (len(string) - 1):
# break
# char = string[i]
#
# i += 1
#
# with open('123.txt', 'w') as out_f_obj:
# out_f_obj.write(decrypted)
###8
# dictionary={}
# with open('data.txt') as in_f_obj:
# for line in in_f_obj:
# line = line.lower()
# print(line)
# for word in line.split():
# if word not in dictionary:
# dictionary[word] = 1
# elif word in dictionary:
# dictionary[word] += 1
#
# max_quantity = 1
#
# for key, value in dictionary.items():
# current_quantity = dictionary[key]
# print(current_quantity)
# if current_quantity > max_quantity:
# max_quantity = current_quantity
# word_with_max_quantity = key
# print(word_with_max_quantity)
# print(max_quantity)
#
# with open('output.txt', 'w') as out_f_obj:
# most_popular = (word_with_max_quantity.upper() + ' ' + str(max_quantity))
# out_f_obj.write(most_popular)
# import glob
#
# for name in glob.glob("C:\\Users\\bulig\\.keras\\datasets\\PBC_dataset_normal_DIB\\**.jpg"):
# print(open(name))
# import os
# import shutil
# from PyQt5.QtWidgets import QFileDialog
# path='C:\\Users\\bulig\\.keras\\datasets\\test'
# papka=[]
# files_names=[]
# i=0
# q=0
# list = os.listdir('C:\\Users\\bulig\\.keras\\datasets\\test')
# file_count = len(list)
# for k in range(file_count):
# for p in os.listdir(path):
# full_path = os.path.join(path, p)
# a=[full_path]
# papka+=a
# i+=1
#
# for j in os.listdir(papka[k]):
# full_path = os.path.join(path, j)
# # os.path.isfile(full_path)
# a=[full_path]
# files_names+=a
# q+=1
# print(files_names)
# print(q)
# file_oldname = os.path.join("C:\\Users\\bulig\\PycharmProjects\\pythonProject", "glcm_all.csv")
# file_newname_newfile = os.path.join("C:\\Users\\bulig\\PycharmProjects\\pythonProject", f"glcm_train{k}.csv")
# os.rename(file_oldname, file_newname_newfile)
# import requests
# r = requests.get('https://stepic.org/media/attachments/course67/3.6.3/843785.txt')
# a=r.text
# ouf = open('file.txt', 'w')
# ouf.write(a)
import requests
from pyfiglet import Figlet
import folium
def get_info_by_ip(ip='127.0.0.1'):
try:
response = requests.get(url=f'http://ip-api.com/json/{ip}').json()
print(response)
data={
'[IP]': response.get('query'),
'[Int prov]': response.get('isp'),
'[Org]': response.get('org'),
'[Country]':response.get('country'),
'[Region name]':response.get('regionName'),
'[City]': response.get('city'),
'[ZIP]': response.get('zip'),
'[Lat]': response.get('lat'),
'[Lon]': response.get('lon')
}
for k,v in data.items():
print(f'{k}:{v}')
area = folium.Map(location=[response.get('lat'),response.get('lon')])
area.save(f'{response.get("query")}_{response.get("city")}.html')
except requests.exceptions.ConnectionError:
print('[!] Please check your connection!')
def main():
preview_text = Figlet(font='slant')
print(preview_text.renderText('IP INFO'))
ip = input('Please enter a target IP:')
get_info_by_ip(ip=ip)
if __name__ == '__main__':
main()