New to python, How to submit a form

I'm still fairly new to python. But I've been wanting to make a channel for plex.  I've been able to parse webpages and find the url to spefic pages that lead to video files, but with one issue.  In order to get the link to an FLV file, a button needs to be pressed on the site. I know lxml can't do this.  And it seems urllib2 shouldn't be used. So whats the appropriate way to simulate clicking that button and getting a request for plex plugins?

Hi!

You first need to figure out which keys/values are posted and to which URL. You can do that by using the dev tools in your browser (Chrome and Safari come with dev tools out of the box). You can also use other tools to capture the http traffic.

If you have this information, create a dict with the POST values and use HTTP.Request/HTML.ElementFromURL/etc. to do the request:

url = 'http://www.example.com/formpost.php'
post_values = {
  'username': 'blah',
  'some_key': '1234',
  'yet_another_key': 'true'
}
result = HTTP.Request(url, values=post_values).content

By setting the "values" attribute, the request will automatically be a POST request.

Some more info on this can be found in the docs here: http://dev.plexapp.com/docs/api/networkkit.html#HTTP.Request

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.