| 33 |
33 |
if getattr(self, "_scrapfly_only", False): |
| 34 |
34 |
return self._scrapfly_json(url) |
| 35 |
35 |
last_err = None |
|
36 |
+ # myshopify.com bloque les UA navigateur mais accepte le UA curl par |
|
37 |
+ # défaut — ne pas passer -A sur ce domaine. |
|
38 |
+ import urllib.parse as _up |
|
39 |
+ _netloc = _up.urlparse(url).netloc |
|
40 |
+ _ua_args = ([] if _netloc.endswith(".myshopify.com") |
|
41 |
+ else ["-A", self.session.headers["User-Agent"].split(" FabriKaBot")[0]]) |
| 36 |
42 |
# 6 tentatives, backoff long sur 429 : les boutiques à panne |
| 37 |
43 |
# intermittente (ex. boutiquesoha.com) répondent après patience, |
| 38 |
44 |
# là où le repli Scrapfly renvoie parfois 422. |
| 44 |
50 |
_last_shopify_req[0] = time.time() |
| 45 |
51 |
p = subprocess.run( |
| 46 |
52 |
["curl", "-sS", "--compressed", "-L", "--max-time", str(self.timeout), |
| 47 |
|
− "-A", self.session.headers["User-Agent"].split(" FabriKaBot")[0], |
|
53 |
+ *_ua_args, |
| 48 |
54 |
"-w", "\n%{http_code}", url], |
| 49 |
55 |
capture_output=True, text=True, errors="replace") |
| 50 |
56 |
body, _, code = p.stdout.rpartition("\n") |
| 51 |
57 |
|