python pdf2image from link “Unable to get page count”

I have a PDF link I want to convert to an Image so I ran this

import requests
import pdf2image
x = "https://www.criticallink.com/wp-content/uploads/ISO-9001-2015-Certificate.pdf"
pdf = requests.get(x,stream=True,timeout=30)
images = pdf2image.convert_from_bytes(pdf.raw.read())

but I get this error

PDFPageCountError: Unable to get page count.
Syntax Warning: May not be a PDF file (continuing anyway)
Syntax Error (19): Illegal character '>'
Syntax Error (46): Illegal character ')'
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table

what should I do?

UPDATE:

pdf.raw.read()[:100]
b'[email protected]>x8axbex80x8ax9aCx03x15x9aSYnxb5SIxcaYxd1xb6x13Nx80xedxdcx91x99i)Xx9a8Ux98x8axd9xb4xd9x84x9ax94Fx0ex14xa0xb5xcbxacx1dxa6Vxa6rHxb5xb7xa2hZ6x99x9aJdjxe2x909xdcxe5xfe}xcfxf9xdd{xcfxf9xe3x9exbbxfa#'

Answer

So you’re getting a GZIP-encoded response. Try the following.

import gzip
import requests
import pdf2image

url = "https://www.criticallink.com/wp-content/uploads/ISO-9001-2015-Certificate.pdf"
response = requests.get(url, stream=True, timeout=30)
pdf = gzip.open(response.raw)
images = pdf2image.convert_from_bytes(pdf.read())

Alternatively, you can use

import requests
import pdf2image

url = "https://www.criticallink.com/wp-content/uploads/ISO-9001-2015-Certificate.pdf"
response = requests.get(url, timeout=30)
images = pdf2image.convert_from_bytes(response.content)

and let requests do the decoding for you.