How to download .csv file with log in required using python?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am trying to log in to download a .csv file from this url
https://www.mapmyfitness.com/workout/export/csv. The url redirects the page to this url:
https://www.mapmyfitness.com/auth/login?next=/workout/export/csv



I have tried implemented the below code but come up with this error:



username = 'email'
password = 'password'

url1 = 'https://www.mapmyfitness.com/workout/export/csv'
url2 = 'https://www.mapmyfitness.com/auth/login?next=/workout/export/csv'

payload = {'email': username, 'password': password}
requests.post(url2, data=payload)

with requests.Session() as s:
p = s.post(url2, data=payload)
print(p.text)

r = s.get(url2)
# print(r.text)

{"error":"validation/username,password","error_description":"Post body failed validation: {"username":"validation/string","password":"validation/string"}"}


I have tried numerous other things but this is the closest I've got to the page not just spitting back the HTML information on the log-in page. Any help would be appreciated!










share|improve this question


















  • 2





    The error is telling you it requires a payload field of username and password, not email and password.

    – eatmeimadanish
    Nov 16 '18 at 15:06











  • @eatmeimadanish tried it, still the same error!

    – road_to_quantdom
    Nov 16 '18 at 15:13











  • Oh I see your problem, this doesn't work like that. The webpage is expecting values input into those fields. It is not an api route call.

    – eatmeimadanish
    Nov 16 '18 at 15:14











  • You should be able to login if you pass your post data to the json parameter, and change 'email' to 'username'.

    – t.m.adam
    Nov 16 '18 at 16:25











  • you need to login with s.post(url,json={"username":"kcy@outlook.com","password":"dafcasdadad"}). Note: i do not have an account that i can not figure out if it needs cookie.

    – kcorlidy
    Nov 17 '18 at 2:49


















0















I am trying to log in to download a .csv file from this url
https://www.mapmyfitness.com/workout/export/csv. The url redirects the page to this url:
https://www.mapmyfitness.com/auth/login?next=/workout/export/csv



I have tried implemented the below code but come up with this error:



username = 'email'
password = 'password'

url1 = 'https://www.mapmyfitness.com/workout/export/csv'
url2 = 'https://www.mapmyfitness.com/auth/login?next=/workout/export/csv'

payload = {'email': username, 'password': password}
requests.post(url2, data=payload)

with requests.Session() as s:
p = s.post(url2, data=payload)
print(p.text)

r = s.get(url2)
# print(r.text)

{"error":"validation/username,password","error_description":"Post body failed validation: {"username":"validation/string","password":"validation/string"}"}


I have tried numerous other things but this is the closest I've got to the page not just spitting back the HTML information on the log-in page. Any help would be appreciated!










share|improve this question


















  • 2





    The error is telling you it requires a payload field of username and password, not email and password.

    – eatmeimadanish
    Nov 16 '18 at 15:06











  • @eatmeimadanish tried it, still the same error!

    – road_to_quantdom
    Nov 16 '18 at 15:13











  • Oh I see your problem, this doesn't work like that. The webpage is expecting values input into those fields. It is not an api route call.

    – eatmeimadanish
    Nov 16 '18 at 15:14











  • You should be able to login if you pass your post data to the json parameter, and change 'email' to 'username'.

    – t.m.adam
    Nov 16 '18 at 16:25











  • you need to login with s.post(url,json={"username":"kcy@outlook.com","password":"dafcasdadad"}). Note: i do not have an account that i can not figure out if it needs cookie.

    – kcorlidy
    Nov 17 '18 at 2:49














0












0








0








I am trying to log in to download a .csv file from this url
https://www.mapmyfitness.com/workout/export/csv. The url redirects the page to this url:
https://www.mapmyfitness.com/auth/login?next=/workout/export/csv



I have tried implemented the below code but come up with this error:



username = 'email'
password = 'password'

url1 = 'https://www.mapmyfitness.com/workout/export/csv'
url2 = 'https://www.mapmyfitness.com/auth/login?next=/workout/export/csv'

payload = {'email': username, 'password': password}
requests.post(url2, data=payload)

with requests.Session() as s:
p = s.post(url2, data=payload)
print(p.text)

r = s.get(url2)
# print(r.text)

{"error":"validation/username,password","error_description":"Post body failed validation: {"username":"validation/string","password":"validation/string"}"}


I have tried numerous other things but this is the closest I've got to the page not just spitting back the HTML information on the log-in page. Any help would be appreciated!










share|improve this question














I am trying to log in to download a .csv file from this url
https://www.mapmyfitness.com/workout/export/csv. The url redirects the page to this url:
https://www.mapmyfitness.com/auth/login?next=/workout/export/csv



I have tried implemented the below code but come up with this error:



username = 'email'
password = 'password'

url1 = 'https://www.mapmyfitness.com/workout/export/csv'
url2 = 'https://www.mapmyfitness.com/auth/login?next=/workout/export/csv'

payload = {'email': username, 'password': password}
requests.post(url2, data=payload)

with requests.Session() as s:
p = s.post(url2, data=payload)
print(p.text)

r = s.get(url2)
# print(r.text)

{"error":"validation/username,password","error_description":"Post body failed validation: {"username":"validation/string","password":"validation/string"}"}


I have tried numerous other things but this is the closest I've got to the page not just spitting back the HTML information on the log-in page. Any help would be appreciated!







python python-requests






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 15:03









road_to_quantdomroad_to_quantdom

8821916




8821916








  • 2





    The error is telling you it requires a payload field of username and password, not email and password.

    – eatmeimadanish
    Nov 16 '18 at 15:06











  • @eatmeimadanish tried it, still the same error!

    – road_to_quantdom
    Nov 16 '18 at 15:13











  • Oh I see your problem, this doesn't work like that. The webpage is expecting values input into those fields. It is not an api route call.

    – eatmeimadanish
    Nov 16 '18 at 15:14











  • You should be able to login if you pass your post data to the json parameter, and change 'email' to 'username'.

    – t.m.adam
    Nov 16 '18 at 16:25











  • you need to login with s.post(url,json={"username":"kcy@outlook.com","password":"dafcasdadad"}). Note: i do not have an account that i can not figure out if it needs cookie.

    – kcorlidy
    Nov 17 '18 at 2:49














  • 2





    The error is telling you it requires a payload field of username and password, not email and password.

    – eatmeimadanish
    Nov 16 '18 at 15:06











  • @eatmeimadanish tried it, still the same error!

    – road_to_quantdom
    Nov 16 '18 at 15:13











  • Oh I see your problem, this doesn't work like that. The webpage is expecting values input into those fields. It is not an api route call.

    – eatmeimadanish
    Nov 16 '18 at 15:14











  • You should be able to login if you pass your post data to the json parameter, and change 'email' to 'username'.

    – t.m.adam
    Nov 16 '18 at 16:25











  • you need to login with s.post(url,json={"username":"kcy@outlook.com","password":"dafcasdadad"}). Note: i do not have an account that i can not figure out if it needs cookie.

    – kcorlidy
    Nov 17 '18 at 2:49








2




2





The error is telling you it requires a payload field of username and password, not email and password.

– eatmeimadanish
Nov 16 '18 at 15:06





The error is telling you it requires a payload field of username and password, not email and password.

– eatmeimadanish
Nov 16 '18 at 15:06













@eatmeimadanish tried it, still the same error!

– road_to_quantdom
Nov 16 '18 at 15:13





@eatmeimadanish tried it, still the same error!

– road_to_quantdom
Nov 16 '18 at 15:13













Oh I see your problem, this doesn't work like that. The webpage is expecting values input into those fields. It is not an api route call.

– eatmeimadanish
Nov 16 '18 at 15:14





Oh I see your problem, this doesn't work like that. The webpage is expecting values input into those fields. It is not an api route call.

– eatmeimadanish
Nov 16 '18 at 15:14













You should be able to login if you pass your post data to the json parameter, and change 'email' to 'username'.

– t.m.adam
Nov 16 '18 at 16:25





You should be able to login if you pass your post data to the json parameter, and change 'email' to 'username'.

– t.m.adam
Nov 16 '18 at 16:25













you need to login with s.post(url,json={"username":"kcy@outlook.com","password":"dafcasdadad"}). Note: i do not have an account that i can not figure out if it needs cookie.

– kcorlidy
Nov 17 '18 at 2:49





you need to login with s.post(url,json={"username":"kcy@outlook.com","password":"dafcasdadad"}). Note: i do not have an account that i can not figure out if it needs cookie.

– kcorlidy
Nov 17 '18 at 2:49












1 Answer
1






active

oldest

votes


















1














Your issue is you are trying to treat the login page like an API call and those are different animals. You would need to have python (selenium can do this) actually fill in the actual input fields and parse the result. This seems cumbersome, and any change to the web page breaks this.



It looks like they have an API for their software, you should actually look at this:



https://developer.underarmour.com/



Clicking a button with Selenium pulled from How to press login button in selenium python 3



xpath:



elem = driver.find_element_by_xpath("//input[@class='userid-button'][@type='submit']")
elem.click()


css:



elem = driver.find_element_by_css_selector("input.userid-button[type=submit]")
elem.click()





share|improve this answer


























  • thanks! I will check out getting API access. For now, I got a almost working solution using selenium. Do you know how I would be able to click the log in button there? I inspect the button and I'm not sure how to select it to click. I use find_element_by_id for email and password. But it doesn't seem that the button has an id

    – road_to_quantdom
    Nov 16 '18 at 16:16











  • i wound up using xpath instead!

    – road_to_quantdom
    Nov 16 '18 at 16:27











  • Ok great! Glad this got you in the right direction!

    – eatmeimadanish
    Nov 16 '18 at 17:23












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340380%2fhow-to-download-csv-file-with-log-in-required-using-python%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Your issue is you are trying to treat the login page like an API call and those are different animals. You would need to have python (selenium can do this) actually fill in the actual input fields and parse the result. This seems cumbersome, and any change to the web page breaks this.



It looks like they have an API for their software, you should actually look at this:



https://developer.underarmour.com/



Clicking a button with Selenium pulled from How to press login button in selenium python 3



xpath:



elem = driver.find_element_by_xpath("//input[@class='userid-button'][@type='submit']")
elem.click()


css:



elem = driver.find_element_by_css_selector("input.userid-button[type=submit]")
elem.click()





share|improve this answer


























  • thanks! I will check out getting API access. For now, I got a almost working solution using selenium. Do you know how I would be able to click the log in button there? I inspect the button and I'm not sure how to select it to click. I use find_element_by_id for email and password. But it doesn't seem that the button has an id

    – road_to_quantdom
    Nov 16 '18 at 16:16











  • i wound up using xpath instead!

    – road_to_quantdom
    Nov 16 '18 at 16:27











  • Ok great! Glad this got you in the right direction!

    – eatmeimadanish
    Nov 16 '18 at 17:23
















1














Your issue is you are trying to treat the login page like an API call and those are different animals. You would need to have python (selenium can do this) actually fill in the actual input fields and parse the result. This seems cumbersome, and any change to the web page breaks this.



It looks like they have an API for their software, you should actually look at this:



https://developer.underarmour.com/



Clicking a button with Selenium pulled from How to press login button in selenium python 3



xpath:



elem = driver.find_element_by_xpath("//input[@class='userid-button'][@type='submit']")
elem.click()


css:



elem = driver.find_element_by_css_selector("input.userid-button[type=submit]")
elem.click()





share|improve this answer


























  • thanks! I will check out getting API access. For now, I got a almost working solution using selenium. Do you know how I would be able to click the log in button there? I inspect the button and I'm not sure how to select it to click. I use find_element_by_id for email and password. But it doesn't seem that the button has an id

    – road_to_quantdom
    Nov 16 '18 at 16:16











  • i wound up using xpath instead!

    – road_to_quantdom
    Nov 16 '18 at 16:27











  • Ok great! Glad this got you in the right direction!

    – eatmeimadanish
    Nov 16 '18 at 17:23














1












1








1







Your issue is you are trying to treat the login page like an API call and those are different animals. You would need to have python (selenium can do this) actually fill in the actual input fields and parse the result. This seems cumbersome, and any change to the web page breaks this.



It looks like they have an API for their software, you should actually look at this:



https://developer.underarmour.com/



Clicking a button with Selenium pulled from How to press login button in selenium python 3



xpath:



elem = driver.find_element_by_xpath("//input[@class='userid-button'][@type='submit']")
elem.click()


css:



elem = driver.find_element_by_css_selector("input.userid-button[type=submit]")
elem.click()





share|improve this answer















Your issue is you are trying to treat the login page like an API call and those are different animals. You would need to have python (selenium can do this) actually fill in the actual input fields and parse the result. This seems cumbersome, and any change to the web page breaks this.



It looks like they have an API for their software, you should actually look at this:



https://developer.underarmour.com/



Clicking a button with Selenium pulled from How to press login button in selenium python 3



xpath:



elem = driver.find_element_by_xpath("//input[@class='userid-button'][@type='submit']")
elem.click()


css:



elem = driver.find_element_by_css_selector("input.userid-button[type=submit]")
elem.click()






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 16 '18 at 17:25

























answered Nov 16 '18 at 15:07









eatmeimadanisheatmeimadanish

1,3731511




1,3731511













  • thanks! I will check out getting API access. For now, I got a almost working solution using selenium. Do you know how I would be able to click the log in button there? I inspect the button and I'm not sure how to select it to click. I use find_element_by_id for email and password. But it doesn't seem that the button has an id

    – road_to_quantdom
    Nov 16 '18 at 16:16











  • i wound up using xpath instead!

    – road_to_quantdom
    Nov 16 '18 at 16:27











  • Ok great! Glad this got you in the right direction!

    – eatmeimadanish
    Nov 16 '18 at 17:23



















  • thanks! I will check out getting API access. For now, I got a almost working solution using selenium. Do you know how I would be able to click the log in button there? I inspect the button and I'm not sure how to select it to click. I use find_element_by_id for email and password. But it doesn't seem that the button has an id

    – road_to_quantdom
    Nov 16 '18 at 16:16











  • i wound up using xpath instead!

    – road_to_quantdom
    Nov 16 '18 at 16:27











  • Ok great! Glad this got you in the right direction!

    – eatmeimadanish
    Nov 16 '18 at 17:23

















thanks! I will check out getting API access. For now, I got a almost working solution using selenium. Do you know how I would be able to click the log in button there? I inspect the button and I'm not sure how to select it to click. I use find_element_by_id for email and password. But it doesn't seem that the button has an id

– road_to_quantdom
Nov 16 '18 at 16:16





thanks! I will check out getting API access. For now, I got a almost working solution using selenium. Do you know how I would be able to click the log in button there? I inspect the button and I'm not sure how to select it to click. I use find_element_by_id for email and password. But it doesn't seem that the button has an id

– road_to_quantdom
Nov 16 '18 at 16:16













i wound up using xpath instead!

– road_to_quantdom
Nov 16 '18 at 16:27





i wound up using xpath instead!

– road_to_quantdom
Nov 16 '18 at 16:27













Ok great! Glad this got you in the right direction!

– eatmeimadanish
Nov 16 '18 at 17:23





Ok great! Glad this got you in the right direction!

– eatmeimadanish
Nov 16 '18 at 17:23




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340380%2fhow-to-download-csv-file-with-log-in-required-using-python%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine