Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sample website and port check
#!/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
You can’t perform that action at this time.