import time
import requests
import urllib.request
import socket
import socks
import locale
import warnings
start_time = time.time()
locale.setlocale(locale.LC_ALL, '')
warnings.filterwarnings('ignore')
url = 'http://ifconfig.io/ip'
socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", port=9050)
socket.socket = socks.socksocket
res = urllib.request.urlopen(url).read()
print (res.decode())
end = round(time.time() - start_time, 2)
print(f'--- {end} seconds ---')
start_time = time.time()
proxy = {
'http': 'http://111.68.26.237:8080',
'https': 'https://111.68.26.237:8080'
}
addr = requests.get(url, proxies=proxy).text
print (addr)
end = round(time.time() - start_time, 2)
print(f'--- {end} seconds ---')
209.141.57.164
--- 0.82 seconds ---
111.68.26.237
--- 14.54 seconds ---
#!/usr/bin/env python3.9
import json
import re
from collections import Counter
with open('/home/delvin/codding/pogoda/sensorsNearby.json') as json_facta:
fact = json.load(json_facta)
json_facta.close()
array = fact['devices']
numkeys = Counter(i for val in array for i in val)['id']
startnum = 0
sensor = 0
unit = ''
pressure = 0
while startnum <= numkeys:
for device in fact['devices']:
if device['location'] == "Ленинск-Кузнецкий, Городская ул., 10":
pressure = device['id']
temperature = device['sensors'][-1]['value']
temperature = round(temperature)
unit = device['sensors'][-1]['unit']
startnum += 1
print (f"{temperature}{unit}")
27°
import requests
headers = {
'User-Agent': ('Mozilla/5.0 (Windows NT 6.0; rv:14.0) Gecko/20100101 '
'Firefox/14.0.1'),
'Accept':
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language':
'ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3',
'Accept-Encoding':
'gzip, deflate',
'Connection':
'keep-alive',
'DNT':
'1'
}
url = f'https://subtitry.ru/'
response = requests.post(url, headers=headers).text
print(response)
from PyQt5 import QtWidgets, uic
import sys
from pyowm import OWM
class Ui(QtWidgets.QMainWindow):
def __init__(self):
super(Ui, self).__init__()
uic.loadUi('weather.ui', self)
city = "Ленинск-Кузнецкий"
owm = OWM('31dd6799e9426588099cc987780b7eb6')
mgr = owm.weather_manager()
observation = mgr.weather_at_place(city)
w = observation.weather
temperature = w.temperature('celsius')['temp']
self.label.setText( f'В городе: {city} сейчас температура: {temperature}')
self.show()
app = QtWidgets.QApplication(sys.argv)
window = Ui()
app.exec_()
index = friends[3]
print('Привет, ' + friends[index] + ', я Анфиса!')
#friends[index]