Use "ping" on a site with Python

5

In Windows CMD, you can use the ping command to get IP from certain sites, for example:

ping www.facebook.com.br

Is there any way to do something similar using Python 3.4?

    
asked by anonymous 24.07.2014 / 00:24

2 answers

5

I assume it's on windows, right? That is, I think, I can not test. I took from here .

from subprocess import check_output
check_output("ping www.facebook.com", shell=True)
    
24.07.2014 / 00:33
5

In Linux, already inside the shell of Python 3.2.3, simply simply::

import subprocess

a=subprocess.Popen("ping -c4 www.boadica.com.br", shell=True)

It should work fine on Windows

    
12.08.2014 / 17:29