How to use get_ip_local method in autotest

Best Python code snippet using autotest_python

get_ip_public.py

Source:get_ip_public.py Github

copy

Full Screen

...27 return ip_public28 except:29 return '0.0.0.0'30 @staticmethod31 def get_ip_local():32 """33 查询本机内网IP34 :return:35 """36 try:37 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)38 s.connect(('8.8.8.8', 80))39 ip = s.getsockname()[0]40 finally:41 s.close()42 return ip43if __name__ == '__main__':44 print("内网IP:{}".format(IP.get_ip_local()))45 print("外网IP:{}".format(IP.get_ip_public()))46 title= "get_ip_public"47 content = IP.get_ip_public()...

Full Screen

Full Screen

ip_address.py

Source:ip_address.py Github

copy

Full Screen

2from bs4 import BeautifulSoup3HEADER = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"4 " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",5 }6def get_ip_local(ip):7 resp = requests.get('https://api.binstd.com/ip/location?appkey=yourappkey&ip={}'.format(ip), headers=HEADER)8 print(resp.json())9 html = BeautifulSoup(resp.text, features="lxml")10 tab0_address = html.find('div', {'id': 'tab0_address'})11 result = tab0_address.text12 # 中国 浙江省 杭州市 阿里云13 # 中国 广西 来宾市 联通14 # 中国 广西 来宾市 移动15 if '市' in result:16 ret = result.strip().split(' ')[2]17 print(ret)18 return ret19if __name__ == '__main__':20 ip = '117.182.155.183'...

Full Screen

Full Screen

get_login_addr.py

Source:get_login_addr.py Github

copy

Full Screen

...6 page = urllib.urlopen(url)7 html = page.read()8 return html9# string -> string10def get_ip_local(ip):11 html = getHtml("http://www.ip138.com/ips138.asp?ip="+ip+"&action=2")12 u = html.decode('gbk')13 r = u.encode('utf8')14 m=re.search(r'<li>([^li<>]*)</li>',r)15 return m.group(1)16# string -> string | None17def get_ip(str):18 m=re.search(r'([0-9]{1,3}(\.[0-9]{1,3}){3})',str)19 if(m):20 return m.group(1)21 else:22 return None23# -> [string] | []24def get_last_login_ip():25 p = subprocess.Popen('last', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)26 ips = []27 for line in p.stdout.readlines():28 ip = get_ip(line)29 if(ip):30 ips.append(ip)31 return ips32for ip in get_last_login_ip():...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful