Commit bb8ca09
committed
scrape_config,client: support proxified_response (raw upstream pass-through)
ScrapeConfig adds a proxified_response: Optional[bool] field that
serializes to the proxified_response query param. When true, the
scrape API returns the raw upstream response body (target's status,
headers, body) instead of the JSON envelope — that's the documented
"use Scrapfly as an HTTP proxy" mode.
The default ScrapeApiResponse parser would crash on the raw body
because it expects {result, context, config}. To support the
proxified mode, client.scrape() now branches: if proxified_response
is true, skip _handle_response() and return the underlying
requests.Response directly. Callers drive it like any HTTP response
and can read X-Scrapfly-* metadata from response.headers
(Api-Cost, Content-Format, Log).
The change is backwards-compatible — customers only opt into the
new return type when they explicitly set proxified_response=true.1 parent a3eae4d commit bb8ca09
2 files changed
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
494 | 506 | | |
495 | 507 | | |
496 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
154 | | - | |
| 155 | + | |
| 156 | + | |
155 | 157 | | |
156 | 158 | | |
157 | 159 | | |
| |||
205 | 207 | | |
206 | 208 | | |
207 | 209 | | |
| 210 | + | |
208 | 211 | | |
209 | 212 | | |
210 | 213 | | |
| |||
262 | 265 | | |
263 | 266 | | |
264 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
265 | 271 | | |
266 | 272 | | |
267 | 273 | | |
| |||
0 commit comments