a file: https://yadi.sk/d/xsjJ3dEqb4pvlQ (it is open)
how to download it to me? do not need authorization, etc.
Answer 1, Authority 100%
Here is the code to download the published file.
(Your link for some reason, the dummy, I for example put your link. Replace it on its work, when it will have)
import requests
from urllib.parse import urlencode
base_url = 'https://cloud-api.yandex.net/v1/disk/public/resources/download?'
public_key = 'https://yadi.sk/d/UJ8VMK2Y6bJH7A' # This inscribe your link
# Get the download link
final_url = base_url + urlencode (dict (public_key = public_key))
response = requests.get (final_url)
download_url = response.json () [ 'href']
# Load the file and save it
download_response = requests.get (download_url)
with open ( 'downloaded_file.txt', 'wb') as f: # Here specify the correct path to the file
f.write (download_response.content)
Answer 2, Authority 29%
Download .csv in DataFrame Pandas with Yandex disk without authorization, in the presence of references to the public folder and file
Library:
import pandas as pd
Import Requests.
import urllib
Import json.
Visitor (links to files and folders can be copied in the publication):
folder_url = 'https://yadi.sk/d/my_folder_hash'
file_url = 'file.csv'
url = 'https://cloud-api.yandex.net/v1/disk/public/resources/download' + + urllib.parse.quote (folder_url) + '& amp; path = /' 'public_key =?' + urllib .parse.quote (file_url)
Prepare the download link:
r = requests.get (url) # request the download link
h = json.loads (r.text) [ 'href'] # 'parsing' download link
Download data DataFrame:
df = pd.read_csv (h, sep = ';', error_bad_lines = False, comment = '#', encoding = 'cp1251')
You have to understand the correct delimiter and character, I have this sep = ‘;’ and encoding = ‘cp1251’.