Prevent a user from going to any other URL [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am presently working on a Raspberry Pi 2 running Raspbian Jessie membership registration kiosk our tech work-space. I have worked out most of the issues such as closing the browser, right-clicking, keyboard shortcuts, and secure login for admins.
The problem I've run into is that the website, that is not under my control, has links to outside websites that I don't want our users going to check the present URL make sure that it is the one approved URL and redirect if it isn't. I've researched doing this with software such as Privoxy and squid and also Python but so far haven't found anything that works. I am very new to Python though it seems the most likely solution, Privoxy just doesn't work, and it seems Squid really wasn't meant for what I'm trying to do.
The overall goal is to ensure a good, consistent interaction between the users and the kiosk so that we're not having to constantly reset the device and field questions like, "why doesn't it work?"
I'll keep searching and post anything that I find but thanks for your help.

One possible solution is to create your own web browser application. You can do this with Chromium Embedded Framework, which allows you to embed Chrome inside your application with only a few lines of code. CEF has Python bindings, if that's your preferred language. In order to restrict navigation, you would create a custom RequestHandler subclass and write an OnBeforeBrowse() function that prevents the user from navigating to external sites. Control is fairly fine-grained, so you can write different rules for handling iframe versus main window navigation.
You may also want to look at the LifespanHandler, which handles pop-up windows.
Be careful about purging data between user sessions, an easy way to do this is to terminate the application and restart it.

Related

Selenium Python Upload Files To Google Keep [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
How to upload image files to google keep using selenium.
Please reply as soon as possible.
I have tried to find the hidden input tag but it was unsuccessful and I don't want to use pyautogui or any other GUI automation framework JUST SELENIUM.
Please reply as soon as possible.
Question is unclear. Selenium can't programmatically upload anything, you'd need a request framework to hit the Google Keep API (if there is one) to do that.
You can use Selenium to navigate the DOM of Google Keep and follow the exact same process as you would by doing it manually. However, once you're trying to find the files on disk, the prompt for this is no longer part of the DOM - I do not believe selenium can interact with this, it would still require manual intervention.
Based on this answer, and the other answers to the same question, https://stackoverflow.com/a/8852686/7532703 - it seems like people have had luck using AutoIT.
Edit from the comments:
I found this https://stackoverflow.com/a/33526707/7532703 - which uses a combination of Selenium and C# to interact with the dialog window, you'd have to either do this in C# or find something that you can do the same thing with in python

A safe way to make an website run a python script [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I made a small script that solves an combinatorial optimization problem and I would like put it in a website so users can "play" with it, they could send a list of "points" to the server and this script would use a database to return the best combination of these "points".
The problem is I do not have much experience in web dev. I searched how to make an html button execute an script and I found this thread: https://stackoverflow.com/questions/48552343/how-can-i-execute-a-python-script-from-an-html-button#:~:text=To%20run%2C%20open%20command%20prompt,Hope%20this%20helpful.
But there says that an html button calling an python script is not safe. So what would be ideal What would be an ideal, safe alternative so that I could make sure that anyone who accesses my website can execute this script safely?
Well, there's no "easy" answer to your question. What you'd really need to do is to create a web-site in Python on your host computer – using a tool such as Django – and have one of the URLs supported by that website call your script.
Honestly, "what you're asking for here, really isn't the sort of question that StackOverflow is intended to answer." It's too big. Another one of the SE-family sites might be more appropriate, although I'm not quite sure which one ...
The solution that comes to mind would be setting up some Python-API (e.g. with Flask) which you could call with HTTP via JS, having different routes for different usages.
Here's a short overview of Flask showcasing how it could be used.

Possible to bypass Google Verification on Login with Selenium PhantomJS? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I wanted to write a bot to scrape long-time statistics on https://www.bustabit.com/
but I realized they have a google verification on the login form.
Now I was wondering if it's even possible to bypass this security.
I'm using Python with Selenium and PhantomJS
I was thinking about passing PhantomJS Cookies/Sessions from my Chrome Browser after I logged in, so it would auto-connect on Site visit - but is this even possible?
Thanks for any help!
Google's login verification is literally designed to stop bots from being authenticated. I would also not suggest attempting to brute force these puzzles, it's more trouble than its worth.
Depending on how often you create a new web session, you could just navigate to the login page, enter the credentials and then pause the script and prompt a human to solve the captcha, before handing the controls back to selenium.
You could try this: http://scraping.pro/recaptcha-solve-selenium-python/
As far as I am concerned there is nothing publically available that would be able to solve the puzzles. And if there would be, google would quickly fix it. Therefore your best bet would be to bruteforce it. If that still works.

Interacting with a web page with Python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am trying to write a program in Python, so that I can use a Raspberry Pi to take hardware input and then do some IoT stuff as a result.
I'm comfortable with all the hardware stuff, and am pretty sure that I'll be able to figure out how to do Facebook posting and tweeting, but I also want to submit data into a webpage.
I don't have control of the webpage, access to the code or anything like that and it's going to be nigh-on impossible to get the access to the code so I'm relying on inspect element here to get any data which I need. I'm also not supposed to post the URL of the said webpage publicly, as it needs a login which I am not at liberty to release.
I want to interact with several features on the webpage, namely:
A mouse-over drop-down menu
A text entering field
A few buttons
I think that I need to do something with 'event listeners', but I'm unsure how to go about this; I have quite a lot of Python experience but not much web development knowledge.
Thanks

How to externally force a running application to perform basic tasks? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need to develop a code that causes a currently open application (running in the background) to perform basic tasks when a certain condition is met.
Let me explain through a random example…
Imagine I am working on a Microsoft word document and I want it to print exactly every 10 minutes automatically, i.e. without having to physically click the print button. What options do I have to implement something like this? Obviously gaining access to the MS word source code is an option, but is their an easier way…perhaps using a python script?
Thanks,
David
Microsoft Office products, as well as Internet Explorer and some other programs expose a Component Object Model (COM) interface. You can find more detail about COM and how it applies to Python here (including examples). They often expose every action you could do manually in the applications, but are aimed at automation and artificial input.
For a more generic application, you could work with sending messages. There's a Windows function called 'postmessage', and another called 'sendmessage' which have several wrappers in Python.
By the way, the MS Word source code is not freely available.

Categories