Last active
May 22, 2017 15:11
-
-
Save moali87/8192a5a6f9af9a4ab7e2a04016d8f7df to your computer and use it in GitHub Desktop.
sample website and port check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
import socket | |
def get_page_code(): | |
test = requests.get('http://www.google.com') | |
return test.status_code | |
def get_port(port=22): | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
result = sock.connect_ex(('127.0.0.1',port)) | |
return result | |
def test_code(): | |
assert get_page_code() == 200 | |
def test_port(): | |
assert get_port() == 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment