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

16 Replies, 993 Views

For a dead-simple way, why not use `curl` via `os.system`? Not pure Python, but gets the job done:

```python
import os
status = os.system("curl -s -o /dev/null -w '%{http_code}' example.com")
print("Site is up!" if status == 200 else "Something's wrong.")
```

Not elegant, but works in a pinch. For periodic checks, cron is your friend.

Messages In This Thread



Users browsing this thread: 1 Guest(s)