Selenium for Pythonista
jl last edited by
I'm sorry if this is obvious or been covered before, but I couldn't find it in the forum. Is it possible to use selenium with Pythonista?
I'm very new to Python, and using Pythonista to learn in the few free minutes here and there during the day. Most of the applications I want to do with Python involve automation of tasks on various websites. If there is some other module or way to do this other than selenium, I'd be interested in that too - for various reasons, it would be a big help if I could do these automated tasks directly from iOS.
Thanks, and Pythonista is absolutely great! I have some previous coding experience, but there is no way I would have time to learn Python without being able to work on the iPhone. Keep up the great work!
Webmaster4o last edited by
As I understand it, selenium directly controls an actual browser like Firefox running in the same computer. I'd reccommend
mechanizefor browser automation with pythonista.
dgelessus last edited by
Isn't Selenium basically a way to remote-control browsers from Python? I don't know how exactly Selenium does that, but most likely iOS Safari is not one of the supported browsers. If the communication with the browser is (or at least can be) done via network, you could perhaps control a browser on your PC from Pythonista on your iDevice, but that's probably not what you're looking for. You'd need to be in the same local network as your PC, and then you might as well run your script there directly.
There are ways to automate web requests using Pythonista though. The
requestsmodule can be used to communicate with the server (
requestsis much more straightforward to use than
urllib2from the standard library), and HTML can be parsed using Beautiful Soup (
bs4). Those are third-party modules, but Pythonista comes with both of them included. Keep in mind that this is nothing like using Selenium - these modules work at a lower level than a full web browser, so you'll want to use them differently. Instead of trying to simulate the entire "journey" through the website, you'll need to find out which parts are important, what URLs you need to request and what response data you need.
Webmaster4o last edited by
From the selenium docs:
Several browsers/drivers are supported (Firefox, Chrome, Internet Explorer, PhantomJS), as well as the Remote protocol.
I don't know what the "remote protocol" is or how it works, maybe it could control a browser on a desktop computer from your iOS device? I'm doubtful that it will work. I've had success with
mechanizeon pythonista. Sourceforge downloads are awkward on iOS to say the least... You can find an easier-downloadable version here
JonB last edited by