Всем привет. Есть скрипт парсера который копирует изображения. Как можно потом их преобразовать сразу в pdf один файл? Скрипт ниже
import time
import requests as req
import json
import re
url = input("Укажите ссылку: ")
pattern = r"/magazines/([^/]+)/issues/([^/]+)/"
match = re.search(pattern, url)
if match:
magazine = match.group(1)
issue = match.group(2)
year = issue.split("-")[-1]
print(magazine, issue, year)
else:
print("Что-то пошло не так")
url = f'http://xn--80aj3aega.xn--p1ai/api/v1/issuepage/?issue={issue}&limit=0&magazine={magazine}&offset=0'
response = req.get(url)
json_data = json.loads(response.text)
file_high_list = [obj['file_high'] for obj in json_data['objects']]
for i in file_high_list:
time.sleep(0.2)
filename = i.split("/")[-1]
print(filename)
if year == issue:
resp = f'http://xn--80aj3aega.xn--p1ai/media/private/{magazine}/2023/{issue}/high/' + filename
name = magazine + filename
response = req.get(resp)
with open(name, 'wb') as f:
f.write(response.content)
else:
resp = f'http://xn--80aj3aega.xn--p1ai/media/private/{magazine}/{year}/{issue}/high/' + filename
name = magazine + filename
response = req.get(resp)
with open(name, 'wb') as f:
f.write(response.content)