In Python, how can I log in, respond to a web form via HTTP POST (not url-encoded), and extract the returned XML file?

Basically I try to export the configuration file once a week. Although this product allows you to enter the system manually through the web client, enter some information and return the XML file when sending, there is no way to automate this. I can get away using Python 2.5 (used for a while) or 2.6 (unfamiliar) for this.

  • I think I need to have an authentication method against the product. Although I can view the cookie in Firefox when I viewed the actual file cookie.txt, it wasn’t there. It did not appear after clearing my personal data and re-authentication. It’s strange. Should I be removed for the module Cookie, or can it be some kind of secret authentication method that looks only like cookies? As I know?

  • I think I need a module httplibto perform HTTP POST, but I don’t know how to do the encoding multipart/form-data. Am I missing a convenient option, or is it something that I have to roll on my own?

  • I assume I can return the XML file to HTTPesponsefrom httplib.

I have already loaded web pages through Python, but not using POST, multi-profile encoding and authentication in the mix.

+3
source share

Source: https://habr.com/ru/post/1703595/


All Articles