1 year ago

#358606

test-img

Divyanshu Soni

Exit with code 1 due to network error: SslHandshakeFailedError

I am trying to convert an HTML web page using wkhtmltopdf API and pdfkit library. But when I am entering the URL of any web page it is showing me this error.

Traceback (most recent call last):
 File "c:\\Users\\Fai\\Desktop\\doc\\convert.py", line 13, in \<module\>
  pdfkit.from_url("www.imdb.com/chart/top/", "imdb.pdf", configuration=config)
 File "C:\\Python\\Python310\\lib\\site-packages\\pdfkit\\api.py", line 27, in from_url
  return r.to_pdf(output_path)
 File "C:\\Python\\Python310\\lib\\site-packages\\pdfkit\\pdfkit.py", line 201, in to_pdf
 File "c:\\Users\\Fai\\Desktop\\doc\\convert.py", line 13, in \<module\>
  pdfkit.from_url("www.imdb.com", "imdb.pdf", configuration=config)
 File "C:\\Python\\Python310\\lib\\site-packages\\pdfkit\\api.py", line 27, in from_url
  return r.to_pdf(output_path)
 File "C:\\Python\\Python310\\lib\\site-packages\\pdfkit\\pdfkit.py", line 201, in to_pdf
  self.handle_error(exit_code, stderr)
 File "C:\\Python\\Python310\\lib\\site-packages\\pdfkit\\pdfkit.py", line 155, in handle_error
  raise IOError('wkhtmltopdf reported an error:\\n' + stderr)
OSError: wkhtmltopdf reported an error:
Error: Failed loading page https://www.google.com (sometimes it will work just to ignore this error with --load-error-handling ignore)
Exit with code 1 due to network error: SslHandshakeFailedError

My code:

import os
from docx2pdf import convert
import pdfkit

path_wkhtmltopdf = r'C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)

PATH = "C:/Users/Fai/Desktop/doc"
os.chdir(PATH)

list_dir = os.listdir()

pdfkit.from_url("www.imdb.com", "imdb.pdf", configuration=config)

python

error-handling

wkhtmltopdf

html-to-pdf

sslhandshakeexception

0 Answers

Your Answer

Accepted video resources