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

22 Replies, 1874 Views

Ah, the classic httpx get response body confusion! You’re close, but `.body` isn’t the right attribute. Try `.text` for plain text (like HTML) or `.json()` if the response is JSON.

`.content` gives you raw bytes, which is handy for binary data.

For your example:
```python
response = httpx.get("https://example.com")
print(response.text) # boom, there's your text!
```
Hope that helps!

Messages In This Thread



Users browsing this thread: 1 Guest(s)