nick34992
2/16/2017 - 5:40 PM

Python Module urllib: readlines Function

Python Module urllib: readlines Function

#!/usr/bin/env python3

import sys
from urllib.request import urlopen

try:
    url = str(sys.argv[1])  # arg: URL string
except (IndexError, ValueError):
    print('Please include a URL')
    sys.exit(2)

response = urlopen(url)

for line in response:
    print(line.decode('utf-8'))

'''
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

<head>

'''