Change Google Chrome Settings using Python - python

I am a basic python programmer.
I would like to change the settings of google chrome, especially the proxy and LAN settings automatically with a program.
I tried looking at the webbrowser library, but I don't think its sufficient.
I looked at the selenium library, but I do not know where to start looking for my requirements in the library, could someone provide a resource or a method on how to automate my tasks? I looked at another questions which describes a process using c#. But thats not my problem. I want the required documentation for my exact purpose.
http://seleniumhq.github.io/selenium/docs/api/py/api.html
which of these must I use?

What you need to use is the Selenium WebDriver API, with Python bindings (lots of other languages are also supported, and many frameworks are available).
Here's a good Python example, plus there's a huge number of helpful questions on this site.
Here's a good description of the ChromeDriver (the WebDriver library that automates a Chrome browser) complete with installation instructions and example Python code.
I personally recommend BrowserMob as a proxy server for Selenium. Although it's Java-based, once it's running you can control it via a REST API - I assume you want to be able to manipulate requests/responses, that kind of thing?
In any case, there are lots of proxy servers available, and the configuration to use one within your Python code is pretty standard. See this example (see also the links).

Related

How to use python and wix for web development [duplicate]

I'm trying to integrate backend code into a Wix site. Im not too picky about how I want to do this, or what language to write in (ideally, I have a locally-hosted Java code that I'd love to simply call). I wouldn't mind re-writing it in JavaScript though, or another language. But before I decide that I'm confused about my options. I can code but I'm new to the concepts like modules, APIs, & servers.
According to my research, back-end code with Wix is supposed to be easy (or at least do-able and not THAT complicated)....
From this webpage https://support.wix.com/en/article/corvid-calling-server-side-code-from-the-front-end-with-web-modules,
"Web modules are exclusive to Corvid and enable you to write functions that run server-side in the backend, and easily call them in your client-side code. With web modules you can import functions from backend into files or scripts in public, knowing they will run server-side. Corvid handles all the client-server communication required to enable this access."
And from this: https://www.sitepoint.com/what-is-wix-code/
"It’s serverless: All this added functionality comes in a serverless environment that lets you get your work done without any of the normal full-stack development headaches.
Just code and go: Wix Code has a built-in, online IDE and backend so you can just add the code you need to your page or your site, publish, and you’re live."
So, I thought they have a backend IDE where I can write backend code directly, or I could call my Java program. But, as I tried doing this and finding tutorials, it seems I can really only do this by calling a public API from the backend...?
https://youtu.be/tuu0D1izrUU
But ive also read (and someone who supposedly has done it before told me this) that Wix integrates with node.js, which is a backend version of JavaScript.
Can I use a Wix domain for a NodeJS app?
But, when I go into my Wix site I cannot find any option for using Node JS, and doing research on that gives me no useful results.
So, I'm thoroughly confused on what the capabilities are here. Can someone help me make sense of this?
Why are there no tutorials showing explicit code in the Corvid backend module? What's stopping me from simply writing my Java program there in a module? Do I really need an API endpoint to call and pass to the front end?
Is Node JS supported or not - has anyone done this before?
Also, in one link above they said everything is "serverless". But if I have to set up my own API endpoint won't I need to set up my own server??
There are basically two ways to go about this, which you seem to have already discovered.
Write your backend code in your Wix site. Indeed, the backend is built on Node.js as you can see here. Using this approach you will have to use JavaScript. As you seem to have found, you write this code in the Backend section of your site in a Web Module. Pros: you don't need to worry about managing a server and all your code is in one place.
Expose your already existing Java code as an API that your Wix site can call using the wix-fetch API. Pros: you don't need to rewrite your code.

How to use Firefox add-on SDK / places/bookmarks API from Python

I am looking for a kick-start on how to access Firefox bookmarks, folders and tabs from Python using Firefox SDK.
I already tested accessing places.sqlite through the SQLite3 library, but it can run in read-only mode since Firefox locks the database while in use.
How do I initialize the SDK from Python (3.x but I would be willing to use 2.7 too, in case) and send basic commands like create a folder, create a bookmark or tag it?
As you might have already guessed I am learning and rather inexperienced...
Yet I searched quite a bit without finding anything of value other than this link Manipulating bookmarks using Places that clearly uses some other language.
I have investigated a little further, or better: asked to an experienced friend.
The answer seems to be: you cannot invoke Firefox's SDK from anything different than Javascript. It has no bindings for other languages, also because they could not work in Firefox.
In addition to that the guide I linked might be old, since Firefox has moved onto supporting web extensions.
It looks like I might have to shift my focus back to JS if I want to pursue this project.

Webtest with Selenium - together? Possible? How?

While reading through WebTest documentation, I found a somehow cryptic note about webtest.http.StopableWSGIServer:
StopableWSGIServer is a WSGIServer which run in a separated thread. This allow to use tools like casperjs or selenium.
I know, what WebTest does. It is a package to simulate a web browser, with a very nice API, to test web pages.
I know, what Selenium does. It is a package that allows a programmer to actually use a real web browser to test web pages.
I use both of those tools in my codebase, only separately.
Somehow I can get my head around the thought of using WebTest with Selenium.
Could anybody please elaborate on that? Am I missing something?
My first idea, a bit vague, is to use WebTest API to access pages running inside a browser controller by Selenium. Was it the idea behind webtest-selenium package?
As a side note, webtest-selenium package seems to be in very early stage of development, since a long time. Does anybody know, is it alive?

XAMPP - Execute Python script on web page

How can I execute a Python script on a webpage?
I've used XAMPP to create the Apache server. Are there any tutorials/examples or guides on how to execute a .py script? I'm using Windows 7 and have installed Python on my local machine. If I access the .py script via the web link, it looks as if its HTML code and nothing is executed.
Typically, you don't execute Python in the browser. Instead, the browser accesses a resource (or "webpage", like http://example.com/mypage) by requesting the resource from the server. The server (for example, Apache), when administered correctly, passes off handling of the request to some Python script. Then, your Python script creates some output (for example, HTML) which the server then returns to the browser for the browser to display.
However, some web sites have found it useful to have logic (scripts) run in the browser, rather than on the server. The standard way of doing this is using JavaScript (although in the past there WERE other languages built into browsers, such as VBScript in Internet Explorer).
Right now, pretty much all browsers have settled on JavaScript as THE scripting language in the browser. In order for you to use any other language in the browser (including Python), the browser must support that scripting language (or needs to have an add-on to support that scripting language). Simply having Python installed on your client alongside the browser is not enough. For more information, please see the Python documentation Web Browser Programming.
Another option is to use something like Pyjs. This is a library that has you write your code in Python, and converts the necessary parts to JavaScript. This isn't exactly "Python in the browser", but it might be something you are looking for.
I guess this links will help....
https://community.apachefriends.org/f/viewtopic.php?t=42975
Usually a good resource for Python is the official documentation.
They do a great job of explaining many aspects of Python. Using Python on the web is a big part and they have a great overview.

Python equivalent to Java's JNLP Web Start?

Is there any way to achieve the same functionality in Python, i.e., launching a script from a browser and automatically updating it from a central server location?
Run your app on Jython and use Java Web Start?
From a comment below, http://blog.pyproject.ninja/posts/2016-03-31-web-start-on-jython.html, provides a complete example.
Note that Jython is not Python- some stuff does not work, and notably Jython is only Python-2.7 compatible.
Well this is still not a full match of the features of JNLP but maybe esky is closer to what you want. It's not browser based but once your app is installed on the client it can update itself. It might also lack something in the cross-platform department so depending on your environment YMMV.
Another alternative might be the Dabo framework at dabodev.com. It's been a few years since i looked at that but it still looks like it's alive :-)
You may be able to achieve some functionality with Skulpt although it uses classless python, so its functionality is rather limited.
Well check out this python wiki page as it lays out various options.

Categories