Code:
import magic import requests from fake_useragent import UserAgent img_base64 = requests.get("https://www.nastol.com.ua/pic/201507/2560x1600/nastol.com.ua-143932.jpg", headers={'User-Agent': str(UserAgent().random)}).text mime_type = magic.from_buffer(img_base64, mime=True) print(mime_type) The picture I want to download: https://www.nastol.com.ua/pic/201507/2560x1600/nastol.com.ua-143932.jpg
Mistake:
Traceback (most recent call last): File "test.py", line 8, in mime_type = magic.from_buffer (tender_document_base64, mime = True) File "C: \ Users \ user \ AppData \ Local \ Programs \ Python \ Python35 \ lib \ site-packages \ magic \ magic.py ", line 147, in from_buffer return m.from_buffer (buffer) File" C: \ Users \ user \ AppData \ Local \ Programs \ Python \ Python35 \ lib \ site-packages \ magic \ magic.py ", line 79, in from_buffer return maybe_decode (magic_buffer (self.cookie, buf)) File" C: \ Users \ user \ AppData \ Local \ Programs \ Python \ Python35 \ lib \ site-packages \ magic \ magic.py ", line 263, in magic_buffer return _magic_buffer (cookie, buf, len (buf)) ctypes.ArgumentError: argument 2:: embedded null character
Question:
How can I fix this error?