I want to create a simple script to download file/family from website or cloud storage. I manage to create it using requests package, when I run it from pyCharm it works just fine, but it’s not working when I run it from pyRevit.
__title__ = "Test"
__fullframeengine__ = True
import os.path
import requests
user_path = os.path.expanduser('~')
def download_file(durl):
try:
with requests.get(durl) as req:
filename = req.url[durl.rfind('/')+1:]
path = os.path.join(user_path, 'Downloads', filename)
with open(path, 'wb') as f:
for chunk in req.iter_content(chunk_size=8192):
if chunk:
f.write(chunk)
return filename
except Exception as e:
print e
return None
famurl = 'https://upload.wikimedia.org/wikipedia/en/thumb/6/63/Feels_good_man.jpg/200px-Feels_good_man.jpg'
download_file(famurl)
It was showing some error when I try run in from pyRevit
HTTPSConnectionPool(host=‘en.wikipedia.org’, port=443): Max retries exceeded with url: /wiki/Pepe_the_Frog (Caused by NewConnectionError(‘<VerifiedHTTPSConnection object at 0x00000000000040C1>: Failed to establish a new connection: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions 103.102.166.224:443’,))
If anyone have a solution or similar problem, please share. Thank you.