Using Python To Interact with Webpages [closed]

蹲街弑〆低调 提交于 2020-01-07 07:47:19

问题


In my current job we have a web based Business intelligence tool where every morning i have to create data extracts from the system and paste them into a PowerPoint presentation. I wish to automate this as its repetitive and time consuming (we have also had several redundancies and i have been allocated the analysts work so i also want to try get home before 10pm :)). The bottle neck for generating these reports is running them on the website and then exporting the results to excel as this manual process can take anything from 10 minutes to an hour of waiting.

I would like to create a script that will open up the web page, make the selections in listboxes containing such information as location product etc as well as a date chooser, press an apply button once the report has generated then export it. This would happen during the period when no one is in the office so the files would be ready when i come in to analysis as opposed to just generating the reports

A second smaller question, Is there a quick way to identify the listboxes using firefox or IE explorer so that they can be referenced in the code?

Is this possible in Python? Our IT department are also quite strict so for example i can not install new software but can install libraries for Python

Could anyone point me in the direction of sample code particularly referencing listboxes or date objects?

Thank you very much for your time


回答1:


All this can be done automated using selenium[1] . If you know the class name/id etc for the listboxes, selenium allows you to send click events to the browser for checking/unchecking listboxes. Read up [2] on filling HTML forms using selenium. You can find the relevant code in the documentation links below.

[1] http://selenium-python.readthedocs.org/)
[2] http://selenium-python.readthedocs.org/en/latest/navigating.html#filling-in-forms



来源:https://stackoverflow.com/questions/20940033/using-python-to-interact-with-webpages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!