I have a report that I want to download in a CSV format using a pyhton script. I searched the web for solutions, but none of them worked. This one looked very promising and simple, but unfortunately does not work either. Any ideas would be helpful.
Update: Thats what I am trying to do when using the technique in the link I provided. I get some weird output and I am not sure what it means.
My code:
import requests
l = requests.get("https://login.salesforce.com/?un=MYUSERNAME&pw=MYPASS")
d = requests.get("https://na2.salesforce.com/00O40000003jBbP?export=1&enc=UTF-8&xf=csv",cookies=l.cookies)
print d.content
Output
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<script>
if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('https://login.salesforce.com/?ec=302&startURL=%2F00O40000003jBbP%3Fexport%3D1%26xf%3Dcsv%26enc%3DUTF-8'); } else
if (window.location.replace){
window.location.replace('https://login.salesforce.com/?ec=302&startURL=%2F00O40000003jBbP%3Fexport%3D1%26xf%3Dcsv%26enc%3DUTF-8');
} else {;
window.location.href ='https://login.salesforce.com/?ec=302&startURL=%2F00O40000003jBbP%3Fexport%3D1%26xf%3Dcsv%26enc%3DUTF-8';
}
</script>
</head>
</html>
<!--
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
-->
export=1
andxf=csv
query string arguments.