(path: str, *, query: dict[str, list[str] | str] | None = None, https: bool = True)
| 5 | |
| 6 | |
| 7 | def get_httpbin_url(path: str, *, query: dict[str, list[str] | str] | None = None, https: bool = True) -> str: |
| 8 | query = query or {} |
| 9 | url = None |
| 10 | if os.environ.get('APIFY_HTTPBIN_TOKEN'): |
| 11 | url = urllib.parse.urlparse('https://httpbin.apify.actor') |
| 12 | query['token'] = os.environ['APIFY_HTTPBIN_TOKEN'] |
| 13 | url = url._replace(query=urllib.parse.urlencode(query, doseq=True)) |
| 14 | else: |
| 15 | url = urllib.parse.urlparse('https://httpbin.org') |
| 16 | if query: |
| 17 | url = url._replace(query=urllib.parse.urlencode(query, doseq=True)) |
| 18 | |
| 19 | scheme = 'https' if https else 'http' |
| 20 | url = url._replace(scheme=scheme) |
| 21 | result_url = url._replace(path=path).geturl() |
| 22 | |
| 23 | return result_url.removesuffix('/') |
searching dependent graphs…