Skip to content

Commit 47e473f

Browse files
committed
Merge pull request buriy#73 from alphapapa/patch-1
Using Mozilla User-Agent by default
2 parents 65d1ebb + 8443a87 commit 47e473f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

readability/readability.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,12 +600,15 @@ def main():
600600

601601
file = None
602602
if options.url:
603+
headers = {'User-Agent': 'Mozilla/5.0'}
603604
if sys.version_info[0] == 3:
604605
import urllib.request, urllib.parse, urllib.error
605-
file = urllib.request.urlopen(options.url)
606+
request = urllib.request.Request(options.url, None, headers)
607+
file = urllib.request.urlopen(request)
606608
else:
607609
import urllib2
608-
file = urllib2.urlopen(options.url)
610+
request = urllib2.Request(options.url, None, headers)
611+
file = urllib2.urlopen(request)
609612
else:
610613
file = open(args[0], 'rt')
611614
try:

0 commit comments

Comments
 (0)