Fix cover page: replace 'requests' with 'httpx' to avoid missing dependency
This commit is contained in:
@@ -21,7 +21,7 @@ Environment variables:
|
||||
|
||||
import os
|
||||
import io
|
||||
import requests
|
||||
import httpx
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from docx import Document
|
||||
@@ -65,9 +65,9 @@ def _add_page_break(doc: Document):
|
||||
def _download_image_bytes(url: str) -> Optional[bytes]:
|
||||
"""Download image from URL and return bytes, or None on failure."""
|
||||
try:
|
||||
r = requests.get(url, timeout=10)
|
||||
if r.status_code == 200:
|
||||
return r.content
|
||||
with httpx.stream("GET", url, timeout=10) as resp:
|
||||
if resp.status_code == 200:
|
||||
return resp.content
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user