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

16 Replies, 1008 Views

If you're lazy like me, just use `ping` for a basic check (though it won’t catch HTTP errors):

```python
import subprocess

def ping_site():
try:
subprocess.check_output(["ping", "-c", "1", "example.com"])
print("Site is reachable.")
except:
print("Site is down.")
```

Not perfect, but super fast for a quick code to check a website python script.

Messages In This Thread



Users browsing this thread: 1 Guest(s)