last day (16 days later) » 

6:52 AM
0
Q: Unable to download a csv file from the URL with python script

MongrelI 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 d...

 
You have to submit the login_data
 
I have mentioned login_data on the 6 Line
 
You have defined login_data il line 6 but you don't submit it. Also it seems that you should request the "app-btn-down" link. If you can share the real url i might be able to help more.
 
The actual link is intranet link. So even if i share the link it will not get open.
Any working sample will do. There is a link which needs a login credential, and there is only one download button which is having a different link. when clicked on that link its asking me to save location.
 
Well, as i mentioned previously you hve to login first: session.post(url, data=login_data). Then use session to get the link: r = session.get(link). Finally get the file: csv_file = session.get(i.get('href')).text
 
6:53 AM
Is this the way.
```import requests

session.post(url, data=login_data)
r = session.get(link)
session.get(i.get("https://rh-ops-jp1.ecl.ntt.com/resourceview/?target_atab=&region=16&region=22&region=19&region=4&region=25&region=10&region=7&region=13&channel_name=&contract_id=&tenant_id=&tenant_name=&group=&hostname=&hostname_fuzzy=&target_date=&bm_chassis_target=y&bm_chassis_columns=region&bm_chassis_columns=group&bm_chassis_columns=status&bm_chassis_columns=flavor_name&bm_chassis_columns=channel_name")).text


```
here is the link
This is the download link
https://rh-ops-jp1.ecl.ntt.com/resourceview/download/bm_chassis
 
Not exactly. i is the bs4 element you got from soup.find_all
Hold on, i'll post some code.
 
7:21 AM
ok
 

  last day (16 days later) »