Dynamically read value of html input field: python - python

I have an external browser plugin (which is blackbox to me). This plugin tries to fill values to input fields of html page (on load. I want to make a program, which is able if the external program filled values properly.
So what I want to do is to open an url from my python program in a browser. On load of this page is automatically executed the plugin and tries to insert values. After that I want to find specific input fields and resolve, whether they are filled correctly or not in the current instance of the browser and page.
Is there any way to do such thing using python (standard or 3rd party) modules? Could you recommend me any?
(Note: I also want to build exe file using cx_freeze, so the best would be, if the module does not depend on external files)
Thanks.

I would suggest using PyQt or Selenium.

Related

How to get GPO Client Side Extension Details Using Python?

I'm trying to build GPO parser in Python. In order to do so, I'm using Impacket. For getting the general details about the GPO I'm using LDAP and for reading the files from SYSVOL I'm using SMB. So far I have managed to get GPO by its GUID. The problem is that there is a field which lists the extensions (Computer or User) for any GPO. The list contains GUIDs of Client Side Extensions (CSE) that the GPO is using.
In order to process the CSE I have tried to read files that are related to this extension (after research about this extension). However, there are missing parts that are not appear in the files (as far as I found) but they do exist in other tools that do the same thing (MMC, Get-GPOReport, gpresult).
To make my problem clear I'll give an example. The security CSE defines several things, including password size, logon attempts and more. One of the things the also defined there is weather or not to store the LMHash. this one is set by a registry key. Those settings are defined in a file called GptTml.inf in SYSVOL. The problem is that the display name isn't appear there as well, but tools like Get-GPOReport or MMC are managed to get it. My goal is to get it as well without running new process or tools (CMD or PowerShell), meaning using python only.
I have tried to look in adm/adml files, /root/rsop/computer namespace and more without success. Does someone know how can to get this information?
To be clear the question I'm trying to figure out is How to get any piece of information about some GPO CSE like MMC, Get-GPOReport, gpresult able to do using python?

Is there a way to automatically download data from a utility using python?

I'm trying to download files automatically from a utility, like PG&E, so I can view my statements easily since I have a couple of different accounts for one login. Currently, I'm using python to figure it out, but I'm stuck on how to actually write the code to download the files. As of right now, I can only access all of the statement information within Python, but cannot figure out how to download the actual bills itself. Does anyone have additional information or resources that you can share so I can try downloading bills using python?

Can Not execute Python .py file using RobotFramework like Javascript

Has anyone found a method for executing their .py files from the Robot Framework like you can for JS?
RobotFramework:
Executes the given JavaScript code.
code may contain multiple statements and the return value of last
statement is returned by this keyword.
code may be divided into multiple cells in the test data. In that
case, the parts are catenated together without adding spaces.
If code is an absolute path to an existing file, the JavaScript to
execute will be read from that file. Forward slashes work as a path
separator on all operating systems. The functionality to read the code
from a file was added in SeleniumLibrary 2.5.
Note that, by default, the code will be executed in the context of the
Selenium object itself, so this will refer to the Selenium object. Use
window to refer to the window of your application, e.g.
window.document.getElementById('foo').
Example: Execute JavaScript window.my_js_function('arg1', 'arg2')
Execute JavaScript ${CURDIR}/js_to_execute.js
It's bs that I can't run my .py files this way...
The Execute Javascript extension isn't a part of RobotFramework, it's something added by the Selenium integration, it would therefore follow that you can't use Selenium to execute a .py file.
That said, RobotFramework is written in Python and can obviously be extended with a Python script.
Can you clear up what you're actually trying to achieve here though?
My concern is that if you're using a .py file in your test state to validate your code, isn't that introducing an uncertainty that means that what you're testing is not the same as the code that gets executed when you release your project?
A bit more detail would help a lot here!

Web interface to a Python script, with "streaming text"

I have a Python command-line script that can take some time to run (from 5 seconds to 5 minutes), depending on the checks it does. The script uses many command-line arguments, some mandatory, most optional.
I'd like to "webify" this script, making it possible to access it from a Web browser, but without changing the core python script, so by launching it from something else (like another Python script for instance)
I've used mod_python with Apache before so it's not too much of a problem to build a Python script that generates a Web page with a form and a Submit button and run my core python script from it.
The problem is with the output of the core python script. I don't want to wait until it has completed to display its output in a DIV (or in a FRAME). As soon as it generates a line, I want that line to be displayed on the Web interface, a kind of text streaming in the DIV.
I know how to do this from a Javascript contained in a HTML page or as an external Javascript file, but not from the output of another program.
Any idea how I can achieve this? I prefer to keep it all Python+Apache but if something else is really required (PHP, AJAX, Javascript, ...), I can live with it.
As suggested by whatnick below, I tried to redirect the output of the core python script in a temporary file and display this file using the AJAX Logfile Trailer & Viewer code I found on the Web.
It sort of works but there is still some buffering, as the lines appear in the "log tail page" in several chunks of lines, not lines by lines. This is most probably due to the fact the AJAX script reloads the log file using a timer, every X milliseconds (configurable in the script, used for a Javascript timer). Even if I lower it, it still not fast enough for my core script, which can sometimes output several lines very fast.
You can log the output from your lengthy script to a file and use a javascript timer based code to pull, parse and display content of the log periodically. If pulling the entire log is too much, you can also delegate to a smaller/faster server side python script to parse the log and pass on the tail of the log to the calling javascript. This is how router logs etc. in embedded devices is displayed.
Good luck. Here is a small tutorial on Javascript Timers.
For IE and Firefox, if you stream your response, it will start rendering before the full page is provided. You can thus stream a log of what is going on in the middle of an HTML file. Once the process is completed, you render the rest of the page as normal.
You will have to go through some convolutions to get a normal Python template engine to work with that since they tend to do everything in one shot.
Chrome does not seem to like this very well (I expect that is a webkit thing so you can probably discount Safari from this trick as well) and I am not sure about Opera.

Convert CVS/SVN to a Programming Snippets Site

I use cvs to maintain all my python snippets, notes, c, c++ code. As the hosting provider provides a public web- server also, I was thinking that I should convert the cvs automatically to a programming snippets website.
cvsweb is not what I mean.
doxygen is for a complete project and to browse the self-referencing codes online.I think doxygen is more like web based ctags.
I tried with rest2web, it is requires that I write /restweb headers and files to be .txt files and it will interfere with the programming language syntax.
An approach I have thought is:
1) run source-hightlight and create .html pages for all the scripts.
2) now write a script to index those script .htmls and create webpage.
3) Create the website of those pages.
before proceeding, I thought I shall discuss here, if the members have any suggestion.
What do do, when you want to maintain your snippets and notes in cvs and also auto generate it into a good website. I like rest2web for converting notes to html.
Run Trac on the server linked to the (svn) repository. The Trac wiki can conveniently refer to files and changesets. You get TODO tickets, too.
enscript or pygmentize (part of pygments) can be used to convert code to HTML. You can use a custom header or footer to link to the actual code for download.
I finally settled for rest2web. I had to do the following.
Use a separate python script to recursively copy the files in the CVS to a separate directory.
Added extra files index.txt and template.txt to all the directories which I wanted to be in the webpage.
The best thing about rest2web is that it supports python scripting within the template.txt, so I just ran a loop of the contents and indexed them in the page.
There is still lot more to go to automate the entire process. For eg. Inline viewing of programs and colorization, which I think can be done with some more trials.
I have the completed website here, It is called uthcode.

Categories