spoof user agent to firefox, fixes 403's

This commit is contained in:
hgw 2023-10-02 02:14:36 +00:00
parent f20031b673
commit b92499cf7f

View File

@ -26,7 +26,8 @@ def main(imgPath, delay, ASCIIWIDTH, COLORCHAR, FILLER, fileType):
print('URL') print('URL')
print('Downloading image to ' + "/home/node/app/image." + fileType) print('Downloading image to ' + "/home/node/app/image." + fileType)
#wget.download(imgPath, "/home/node/app/image." + fileType) #wget.download(imgPath, "/home/node/app/image." + fileType)
imagefile = requests.get(imgPath) headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:101.0) Gecko/20100101 Firefox/101.0'}
imagefile = requests.get(imgPath, headers=headers)
open("/home/node/app/image." + fileType, "wb").write(imagefile.content) open("/home/node/app/image." + fileType, "wb").write(imagefile.content)
if fileType == "png": if fileType == "png":
print('PNG') print('PNG')