/
ilya.petrash
/
SimplePyScripts
Обзор
Документация
Войти
/
ilya.petrash
/
SimplePyScripts
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
using_tor/loop_check_url.py
40 строк
923 B
gil9red
Updated. Logger
11 фев 2024, 00:47
11 фев 2024, 00:47
5f4abbc
Код
Авторство
О чём код?
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = "ipetrash" import logging import sys import time # pip install -U requests[socks] import requests proxies = { "http": "socks5://localhost:9050", "https": "socks5://localhost:9050", } # NOTE: Для смены ip нужно настроить tor # Для этого создается torrc файл (\Data\Tor\torrc) # И в него добавляется содержимое: # NewCircuitPeriod 5 # MaxCircuitDirtiness 10 url = "http://httpbin.org/ip" log = logging.getLogger(__file__) log.setLevel(logging.DEBUG) handler = logging.StreamHandler(sys.stdout) handler.setFormatter(logging.Formatter("[%(asctime)s] %(message)s")) log.addHandler(handler) while True: try: log.debug(requests.get(url, proxies=proxies).json()) except requests.exceptions.ConnectionError: log.debug("WARN: Not found Tor") time.sleep(1)