I am making an app which will login to a website and scrape the website for the information I have. I currently have the all the login and web scraping written in Python completely done. What I am trying to figure out is running that python code in Xcode in my swift project. I want to avoid setting up a server capable of executing cgi scripts. Essentially the user will input their credentials and I will pass that to the python file, and the script will run.
1 Answer
Short answer: You don't.
There is no Python interpreter running on iOS, and Apple will likely neither provide nor allow one, since they don't allow you to deliver and run new code to in iOS app once it's installed. The code is supposed to be fixed at install time, and Python is an interpreted language.
6 Comments
johnson
So looks like I'll have to set up a server capable of executing cgi scripts huh?
rmaddy
@johnson You could write your scraping code in Swift instead of Python.
johnson
I use the selenium web driver any way to convert that to work with swift?
Duncan C
Indeed, for an app running on an iOS device, sending HTML off to a server off to be scraped is an awkward, fragile solution. Much better to develop code that will run on the native device. (In this case that means writing the code in Swift, C, Objective-C, or C++.
Actually, there is an iOS python interpreter, with the ability to submit apps based on code written with it. See Pythonista 3 by omz:software appsto.re/us/XxRUab.i
|