Я успешно создаю PDF-файл из URL-адреса, используя pdfkit на английском языке, но в PDF-файле генерируются ненужные символы, если я попробую URL-адрес на другом языке, отличном от английского, мой код:
Код: Выделить всё
options = {
'page-size': 'Letter',
'margin-top': '0.75in',
'margin-right': '0.75in',
'margin-bottom': '0.75in',
'margin-left': '0.75in',
'encoding': "UTF-8",
'custom-header' : [('Accept-Encoding', 'gzip')],
'cookie': [
('cookie-name1', 'cookie-value1'),
('cookie-name2', 'cookie-value2'),
],
'no-outline': None
}
import requests
from bs4 import BeautifulSoup
from urllib import request, response, error, parse
from urllib.request import urlopen
import pdfkit
config=pdfkit.configuration(wkhtmltopdf="c:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe")
pdfkit.from_url(URL,'c:\temp\sample.pdf', configuration=config, options=options)
и мой целевой URL-адрес — https://www .loksatta.com/kolhapur-news/politics-on-the-backdrop-of-the-upcoming-elections-of-the-gokul-district-central-co-operative-banks-abn-97-2195442/
Можете ли вы что-нибудь предложить и помочь?
Спасибо
Подробнее здесь: https://stackoverflow.com/questions/625 ... racter-set