Image Fallback Fetcher for news_fetch¶
The news_fetch Luigi pipeline downloads remote article images and uploads
them to S3 (original / optimized / thumbnail / small). Publishers behind
Cloudflare-style bot protection return 403 Forbidden (or sometimes 503) to
plain requests.get, so the downloader uses a browser-fingerprint fetcher
built on curl_cffi by default.
curl_cffi makes the underlying TLS handshake and HTTP/2 settings match real
Chrome, which is what Cloudflare actually inspects for static-asset URLs.
Fetch path (default)¶
When IMAGE_FALLBACK_ENABLED is true (the default), each image URL is fetched
with one curl_cffi HTTP call (max_retries=0). There is no direct
requests.get first, so blocked URLs do not waste an extra round trip.
Set IMAGE_FALLBACK_ENABLED=false to restore plain requests.get (legacy).
When image upload fails, the article is still returned for DB upsert (text
fields and origin_image_url); only S3 image paths are omitted.
Configuration¶
| Variable | Effect |
|---|---|
IMAGE_FALLBACK_ENABLED |
Default true. Set false/0 for plain requests. |
Local smoke test¶
python3 - <<'PY'
from curl_cffi import requests
url = "https://www.elboletin.com/wp-content/uploads/2020/10/www.elboletin.com_fotos_1_141325_aeropuerto2.jpg"
r = requests.get(url, impersonate="chrome", timeout=10)
print(f"status={r.status_code} bytes={len(r.content)}")
PY
Production deployment¶
curl_cffi ships as a precompiled wheel. A standard pip install -r requirements.txt
is sufficient. Disable with IMAGE_FALLBACK_ENABLED=false if needed.