Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import socket, ssl, re
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
- context.verify_mode = ssl.CERT_REQUIRED
- context.check_hostname = True
- context.load_default_certs()
- hostname = 'www.gprc.ab.ca'
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- ssl_sock = context.wrap_socket(sock, server_hostname=hostname)
- ssl_sock.connect((hostname, 443))
- course = 'cs3130'
- url = 'https://{}/programs/courses/index.html?c_keyword=&c_code={}'
- url = url.format(hostname, course)
- ssl_sock.sendall('GET {} HTTP/1.0\n\n'.format(url).encode('ascii'))
- content = ''
- recv = ssl_sock.recv(2048).decode('ascii')
- while not recv == '':
- content += recv
- recv = ssl_sock.recv(2048).decode('ascii')
- print(content)
- ssl_sock.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement