File tree Expand file tree Collapse file tree 2 files changed +4
-11
lines changed Expand file tree Collapse file tree 2 files changed +4
-11
lines changed Original file line number Diff line number Diff line change 17
17
18
18
__status__ = "Prototype"
19
19
20
- try :
21
- from urllib .request import urlopen
22
- except ImportError :
23
- from urllib import urlopen
24
- from io import open
20
+ import requests
25
21
import argparse
26
22
import sys
27
23
from os .path import isfile
@@ -51,11 +47,7 @@ def get_parser():
51
47
with open (args .input , encoding = args .encoding , errors = 'ignore' ) as f :
52
48
html_content = f .read ()
53
49
elif args .input .startswith ("http://" ) or args .input .startswith ("https://" ):
54
- 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 )
50
+ html_content = requests .get (args .input ).text
59
51
else :
60
52
print ("ERROR: Cannot open input file '{}'.\n " .format (args .input ))
61
53
parser .print_help ()
Original file line number Diff line number Diff line change 37
37
38
38
# Requirements
39
39
install_requires = [
40
- 'lxml'
40
+ 'lxml' ,
41
+ 'requests'
41
42
]
42
43
43
44
)
You can’t perform that action at this time.
0 commit comments