Sending header when requesting a file
This commit is contained in:
parent
90e071354f
commit
210238d086
|
@ -54,6 +54,21 @@ def getFile(fileDir,tempDir,imageURL,indent=0):
|
|||
As too long file names seem not working.
|
||||
"""
|
||||
|
||||
headers = [
|
||||
("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 " \
|
||||
"(KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11"),
|
||||
("Accept", "text/html,application/xhtml+xml,application/xml;" \
|
||||
"q=0.9,*/*;q=0.8"),
|
||||
("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3"),
|
||||
("Accept-Encoding", "none"),
|
||||
("Accept-Language", "en-US,en;q=0.8"),
|
||||
("Connection", "keep-alive")
|
||||
]
|
||||
|
||||
opener = urllib.request.build_opener()
|
||||
opener.addheaders = headers
|
||||
urllib.request.install_opener(opener)
|
||||
|
||||
if not (os.path.isfile(fileDir)):
|
||||
for i in range(3):
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue