Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How to ping a web server in Python 3.10

$
0
0

Alrighty, time to ask a very stupid/obvious question. I need to ping a webserver/website to see if it's valid, using the ICMP protocol. You know...ping facebook.com. My code generates a bunch of TLD's, and subdomain's to a user-inputted domain name. I plan on pinging all of them (it's about 6 usually) to see if they're actually valid before doing what I need to do with them. However, all the tutorials and questions similar to mine are from like 2010 and don't work anymore. The one thing I have got to work printed out the results of the ping, which I don't want. So maybe some sort of function that like below, it just returns or prints out whether or not it's online not actual responses if that makes sense:

def website_checker():     if os.system("ping facebook.com"):          print("facebook.com is valid")     else:          print("facebook.com is not valid")

I'm not sure if that helps but I can't put it into any better words. Please, I'm pulling my hair out


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>