Исправления в подмене заголовка.

This commit is contained in:
2025-11-19 18:03:31 +10:00
parent 16b22c2a4e
commit ce1d04ae64
2 changed files with 7 additions and 3 deletions

View File

@@ -66,7 +66,9 @@ def list_ip(c_dict: dict = []):
# бежим весь список ссылок пока не код 200
for c_url in c_list['url']:
try:
if (result:=requests.get(c_url, headers=get_headers())) and result.status_code == 200 and result.text:
session = requests.Session()
session.headers.update(get_headers())
if (result:=session.get(c_url)) and result.status_code == 200 and result.text:
print(f"URL: {c_url}")
# пополняем словарь ipv4_list
if ipv4: ipv4_list.update(ipv4_find(result.text,ipv4))
@@ -130,7 +132,9 @@ if __name__ == "__main__":
try:
# если файл list ссылка, загружаем и парсим его
with open(list_file, "r") as file:
if (result:=requests.get(url_list_file:=file.readline().strip(), headers=get_headers())) and result.status_code == 200 and result.text:
session = requests.Session()
session.headers.update(get_headers())
if (result:=session.get(url_list_file:=file.readline().strip())) and result.status_code == 200 and result.text:
ip_list = ast.literal_eval(result.text)
print(f"Список выгрузки по url: {url_list_file}")
except requests.exceptions.MissingSchema:

View File

@@ -60,7 +60,7 @@ def get_headers():
("User-Agent", user_agent),
("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"),
("Accept-Language", accept_lang),
("Accept-Encoding", "gzip, deflate, br"),
("Accept-Encoding", "gzip, deflate, br, zstd"),
("Connection", "keep-alive"),
("Upgrade-Insecure-Requests", "1"),
]