代码拉取完成,页面将自动刷新
# Author : RIZWAN AHMAD
# pip3 install requests
import requests
# Function for download file parameter taking as url
def download(url):
f = open('file_name.jpg', 'wb') # opening file in write binary('wb') mode with file_name.ext ext=extension
f.write(requests.get(url).content) # Writing File Content in file_name.jpg
f.close()
print("Succesfully Downloaded")
# Function is do same thing as method(download) do,but more strict
def download_2(url):
try:
response = requests.get(url)
except Exception:
print('Failed Download!')
else:
if response.status_code == 200:
with open('file_name.jpg', 'wb') as f:
f.write(requests.get(url).content)
print("Succesfully Downloaded")
else:
print('Failed Download!')
url = 'https://avatars0.githubusercontent.com/u/29729380?s=400&v=4' # URL from which we want to download
download(url)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。