Need a simple code to check a website in Python—any recommendations? or What’s the best code to check

16 Replies, 814 Views

Honestly, if you just need a quick code to check a website python solution, you could even use `httpx`—it's like `requests` but async-friendly.

```python
import httpx

async def check_site():
try:
async with httpx.AsyncClient() as client:
r = await client.get("https://example.com")
print("Up" if r.status_code == 200 else "Down")
except:
print("Failed to connect.")
```

Bonus: it’s faster for multiple sites!

Messages In This Thread



Users browsing this thread: 1 Guest(s)