You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
457 B
18 lines
457 B
5 years ago
|
import sys
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
try:
|
||
|
from urllib.request import urlopen, URLError
|
||
|
except ImportError:
|
||
|
from urllib2 import urlopen, URLError
|
||
|
|
||
|
url = sys.argv[1]
|
||
|
headers = {"Content-Type": "text/plain; charset=utf-8"}
|
||
|
try:
|
||
|
resp = urlopen(url)
|
||
|
line = resp.readline().decode("ascii") # py3
|
||
|
except URLError:
|
||
|
line = "failed to read %s" % url
|
||
|
sys.stdout.write(line)
|
||
|
sys.stdout.flush()
|