| Server IP : 172.67.158.106 / Your IP : 162.159.114.23 Web Server : nginx/1.30.6 System : Linux alexhost1 7.0.0-44-generic #44-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 6 02:38:04 UTC 2026 x86_64 User : xxbet_company_com ( 1133) PHP Version : 8.5.4 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /data/pbn/parsed_images/ |
Upload File : |
import os
import requests
import re
def sanitize_filename(filename):
"""Удаляет недопустимые символы из имени файла."""
return re.sub(r'[\\/*?:"<>|]', "_", filename)
def download_image(url, save_path):
try:
headers = {
"User-Agent": "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; "
"+http://www.google.com/bot.html) Chrome/W.X.Y.Z Safari/537.36"
}
response = requests.get(url, headers=headers)
response.raise_for_status()
with open(save_path, 'wb') as file:
file.write(response.content)
print(f"Image successfully downloaded: {save_path}")
except Exception as e:
print(f"Error downloading {url}: {e}")
def main():
with open("image_urls.txt", "r") as file:
image_urls = file.read().splitlines()
print(f"Images count: {len(image_urls)}")
save_folder = "downloaded_images"
os.makedirs(save_folder, exist_ok=True)
for i, url in enumerate(image_urls):
if i < 1245:
continue
if not url:
continue
file_extension = url.split('.')[-1].split('?')[0]
filename = f"image_{i + 1}.{file_extension}"
sanitized_filename = sanitize_filename(filename)
save_path = os.path.join(save_folder, sanitized_filename)
download_image(url, save_path)
if __name__ == "__main__":
main()