How do I extract the response body from an httpx GET request? or What's the best way to access the ht

22 Replies, 2236 Views

For the httpx get response body, you’ve got a few choices:
1. `.text`: Decoded text (default UTF-8).
2. `.content`: Raw bytes.
3. `.json()`: If the response is JSON.

Your code should be:
```python
response = httpx.get("https://example.com")
print(response.text) # or .json()
```
Bonus: Use `response.encoding` if the text looks weird.

Messages In This Thread



Users browsing this thread: 1 Guest(s)