We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 502ffea commit a1ef7c8Copy full SHA for a1ef7c8
scripts/inscript.py
@@ -51,7 +51,11 @@ def get_parser():
51
with open(args.input, encoding=args.encoding, errors='ignore') as f:
52
html_content = f.read()
53
elif args.input.startswith("http://") or args.input.startswith("https://"):
54
- html_content = urlopen(args.input).read().decode(args.encoding)
+ http_client = urlopen(args.input)
55
+ if ('Content-Type' in http_client.headers and
56
+ 'charset=' in http_client.headers['Content-Type']):
57
+ args.encoding = http_client.headers['Content-Type'].split('charset=')[1]
58
+ html_content = http_client.read().decode(args.encoding)
59
else:
60
print("ERROR: Cannot open input file '{}'.\n".format(args.input))
61
parser.print_help()
0 commit comments