Chandan
Chandan

Reputation: 759

Submit form using urllib

In Python 2, while submitting forms in webpage, we can use mechanize. Also we can see the forms in the webpage using. But how to do that using urllib in Python 3(i.e finding the forms and submitting the values). I know how to use POST to submit the forms in urllib. But how to fnd the forms? and also how to override the readonly values using urllib?

Upvotes: 0

Views: 393

Answers (1)

Devin Jeanpierre
Devin Jeanpierre

Reputation: 95506

There's no such thing as readonly values in a POST request. If you want to find the forms, you'll have to inspect the HTML yourself, perhaps using lxml.html.

So you would find the <form> element by hand, and then find any <input> elements (and so on) by hand, and then construct a POST request by hand.

However, as Pace pointed out (before deleting his submission), lxml.html has a specific way to access form data, which you might find helpful.

Upvotes: 1

Related Questions