1

I am struggling to post to a javascript/react form with Pythons Requests. I understand the regular way would be something like this

payload = {"user": "me", "password": "12345"}
s = requests.Session()
html = s.post(url, data=payload) `

The url part is the problem, since I cannot find it in the source. The source of the form looks like this:
<form class="Login-form" method="POST" data-reactid="19"> … </form>
I assumed a value for the action parameter but, well, it ain't there. I also tried to find an url in the javascript but to be honest, I can't read it very well.

So my question would be: How – if at all – can I make a post with Requests to a react formular?

Edit:
To make the question more concise and reflect the accepted answer:

If an html-form with javascript has no obvious url in the source where it posts to, how can I find out the url?

2
  • 2
    A form without a action= argument POSTs to the current URL. But since you're dealing with React, it's probably handled by a action to an API endpoint behind the scenes. Watch the network tab under developer tools in your browser of choice to see how it's actually implemented. Commented Aug 20, 2017 at 19:33
  • Thank you. The idea with the network tab actually did the job. I got the url! Commented Aug 20, 2017 at 19:50

1 Answer 1

1

A form without an action= attribute POSTs to the current URL. But since you're dealing with React, it's probably handled by an action to an API endpoint behind the scenes. Watch the network tab under developer tools in your browser of choice to see how it's actually implemented and what URL the React application talks to.

Sign up to request clarification or add additional context in comments.

4 Comments

Thx again. Do you mind hinting at me why I might got downvoted? I get that it is not the most specific question I asked but first, you got it and answered it and second, sometimes it is hard to be more specific since one sails in unknown waters.
No idea. Perhaps someone thought the question lacked enough details to give a good enough answer; in that case I would leave a comment and a close vote at least..
I just updated my question to reflect your answer. Maybe that will help.
No worries. Most people won't go back and read older, solved questions except when they arrive here from Google anyway. Thanks for the update anyway :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.