Home:ALL Converter>Unable to download a csv file from the URL with python script

Unable to download a csv file from the URL with python script

Ask Time:2017-10-09T16:39:52         Author:AReddy

Json Formatter

I am accessing a url with username and password to download a csv and save the file with today's date nad time, there is only one download link on the page.

Is there any way I can achieve this task via python

I am using this below script I see the print output. but how can I download the the download csv button on the web-page. Normally when I click on the download csv button it asking me to save the file.

import re
import requests
from bs4 import BeautifulSoup

url = 'https://url.com'
login_data = dict(login='[email protected]', password='password-g')
session = requests.session()

link = 'https://url.com'

r = requests.get(link)
soup = BeautifulSoup(r.text, "html.parser")

for i in soup.find_all('a', {'class': "app-btn-down"}):
    print(re.search('http://.*\b_file', i.get('href')).group(0)) # the CSV file name is b_file
    print ("r.text")

As I'm new to python, so please forgive me for my bad explanation.

Author:AReddy,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/46642126/unable-to-download-a-csv-file-from-the-url-with-python-script
yy