Pythonista URL Scraper on iOS - iphone

I’ve been attempting to compile a script to give me table data from a few xpaths from https://www.worldometers.info/coronavirus/ to display info from just 4 of the hundreds of datasets.
The issue I’ve run into after playing around with various scripts for hours and hours and doing web searches is that pythonista iOS won’t allow me to utilize pandas, beautiful soup, pyto, or a host of other parsers.
I’m admittedly a noob but it seems like using the basic installed libraries for python 2.7 or 3.2 should be able to simply display Xpath data with a few lines of code with which I will eventually migrate some premade code in iOS shortcuts app to make it a widget for my Apple Watch and/or iPhone.
All this to say... has anyone had success scraping using iOS Pythonista app? If so, any pointers for an angle of attack??

Pythonista is limited by the fact that you must use pure python libraries. This is no fault of the developer and is a restriction set by Apple. I recommend installing StaSh and finding a pure python scraping library that you can install through pip. A quick google search brought up this one which you might find useful.

As of December 2020, Pythonista has the requests and bs4 modules built in.

Related

phonegap 2.2 and facebook integration

I have been recently begin working with phonegap and I notice that there is no tutorial for phonegap 2.2, the most recent version. What's more, since phonegap 2.0 there has apparently been drastic changes. I am having lots of trouble with using phonegap since I am new to web-iphone apps.
I am trying to make an application with phonegap to use facebook log in to get your data (pics, friends, etc) and then post on your facebook page, update status, etc. Basically a social App.
It seems that no tutorial is clear on any facebook-phonegap integration and social web based app.
I have seen a video with phonegap 1.8 tutorial and have followed it very close, only to get many errors.
I followed the one on:
https://github.com/davejohnson/phonegap-plugin-facebook-connect
and have had protocol.
I have tried many different things, but it seems that xcode simply is not able to recognize some functions or protocols. I am looking to see if I missed anything, but Ive added everything according to steps followed.
Ive tried adding the facebook.Framework, the extra headers, heck, Ive even added all of the files from the facebook SDK in the src file of the package:
https://github.com/facebook/facebook-ios-sdk
I cant seem to put together a simple facebook log in app...
anyone got it to work? what are the exact steps to follow? Im good with a new 2.2 cordova project and up until I put the files: FacebookCOnnectPlugin.h and .m that is where everything gets messed up.
I DO have the libsqlite3.0.dylib and HAVE followed the steps, added all the stuff in various .plist and all these weird long and annoying procedures many times...
Ive tried adding various libraries and just can't come up with anything else so why can't I just start a simple cordova project and get the option to log-in connect fb. like a simple hackbook sample.... I get it working in Objective-c demo (new single view application project)... Why does everything have to be so difficult and not working. I just want to get a page to start coding at. Just to get to this point, not even starting is so difficult.
very frustrating....
any help is much appreciated.
-- Im new to web apps and iphone...
I got it working but there are lots of issues and tweaks you need to do in order for it to fully work.
In my experience PhoneGap Plugins do work but you have to play around a lot. E.g. I know for sure the new Facebook SDK is not supported by the PhoneGap plugin. Even if you import the Deprecated Headers. I had to use the older version of the SDK. And also with version 2.7 not all plugins are supported so I had to stick to an older version 2.5 so I could get my project to work.
Even tough I got this plugin to work on iOS, it doesn't work on Android. It's a really good platform to develop on if you're looking for fast productivity but i'm still a bit spectacle on being heavily dependant on the plugins which are not being maintained continuously.
Hope this helps.

libraries / services to assist with iOS wireless app distribution

Can anyone recommend any libraries/utilities they use to assist in distributing iOS adhoc/enterprise applications over the air, so users can install without needing a PC/iTunes?
There's a few hosted services around (eg. https://testflightapp.com/ - though that is not free for enterprise apps), but I'm sure in the past I saw a non-hosted service (ie. something I could install on my own server) and came with a client side library that was easy to hook into the app to notify the user when updates were available and allow them to easily install them. Unfortunately it seems I didn't bookmark it and a bunch of googling and searching on stack overflow hasn't found it.
You need to create your own manifest and bundle it with the app package (the IPA from Build and Archive). There are a lot of guides on the web. e.g. this to automate OTA distribution using Heroku from Héctor Ramos or Mike Nachbaur's write up.
That said, I suspect using TestFlight.app is a lot easier than rolling your own - have you looked at the cost benefit of paying TestFlight vs developing and maintaining your own system. Much better to write production code rather than save the cost of the TestFlight subscription surely...
I finally found the one I believe I was thinking of when I wrote the question, it's called "Hockey":
http://hockeykit.net/
https://github.com/TheRealKerni/HockeyKit
If there are other similar solutions out there, please do add your own answer!

Examples of interpreters embedded in iPhone Applications?

I'm trying to find examples of interpreted languages ported to the iPhone, with source code available to show how to embed it, without Jailbreaking the device:
I've found:
Ruby: http://www.cocos2d-iphone.org/forum/topic/1163
Lua: http://www.mobileorchard.com/announcing-iphone-wax-native-uikit-iphone-apps-written-in-lua/
and I'd like to see what else is out there. I know that Apple may or may not allow usage of an interpreter in an app (or downloading new code to run in the interpeter), but I'm ok with that, as I want this mostly to simplify development.
Are there any other examples out there?
There's Nu.
Nu is a Lisp-on-ObjC-runtime thing. The link above is to information on iPhone embedding. The language homepage is here.
PHP, Python, Tcl.
iPhone Frotz is an interpreter for the Z-Machine and is open source.
How about C#?
And soon also Flash..
The Processing environment has been adapted for the iPhone. I believe that it comes from ProcessingJs which translates the Processing code to Javascript.
Processing for IOS (if the link doesn't work, search for it)
http://itunes.apple.com/sg/artist/boyd-rotgans/id492576046
or a commercial version that allows you to import/export scripts
http://itunes.apple.com/app/pr0c0d1n6/id493549542?mt=8
There is also a tool to convert ProcessingJs scripts to native iPhone Apps.
http://luckybite.com/iprocessing/

Is there any sort of programming environment that runs ON an IPhone?

I'm just recalling the days when Radio Shack used to sell pocket computers. (Many moons ago, w/ only a few K of memory.) They had the ability to write small programs on Pocket computer. Maybe it's just nostalgic, but I alway thought that was handy. (Through the fog of my memory.) Is there any capability like that for an Iphone?
Edit:
I can kinda understand not allowing a like a GameBoy emulator on the App-store, it's kinda like saying your ok with people loading "ROMs" and could get them in trouble. When you start profitting from an Emulator the license holders get pissy, just think about "Bleem" and Sony. Sony buried those guys. I suppose Javascript is better than nothing. What about Java in a sandbox? Or if they want something they aren't afraid is going to cannibalise there market, a BASIC interpreter.
I don't believe that you are allowed to in the terms of service for the App store. Isn't this why mono programs have to be staticly compiled if they are going up to the App store.
If you are looking to go off the beaten path, James Long's blog details how to run Gambit Scheme code on the iPhone. Load the application once and then load code changes progressively as needed.
In a following blog post, he details how to debug your applications remotely with an REPL. Very cool stuff. Between the simplicity of Scheme and the existing work he's done on his blog, a lot of the work/difficulty involved with developing in a "non-standard" way on the iPhone is taken care of for you. It's worth a shot!
Python is possible:
http://mail.python.org/pipermail/python-list/2008-November/686098.html
The only thing remotely close to that (without Jailbreaking) is Javascript/HTML in Mobile Safari.
While "on" your iphone is relative www.tilestack.com is a web based development environment that can produce webapps.
Terminal.app can be compiled for limited distribution (w/o jailbreaking). /bin/sh is a valid programming language. QED.
Yes, it is possible to set up a node.js programming environment that lets you run your own server on the iPad. It's also possible to run javascript using the textastic code editor. See Is it possible to do programming using iPhone?.

Can I write native iPhone apps using 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 3 years ago.
Improve this question
Using PyObjC, you can use Python to write Cocoa applications for OS X. Can I write native iPhone apps using Python and if so, how?
You can use PyObjC on the iPhone as well, due to the excellent work by Jay Freeman (saurik). See iPhone Applications in Python.
Note that this requires a jailbroken iPhone at the moment.
Not currently, currently the only languages available to access the iPhone SDK are C/C++, Objective C and Swift.
There is no technical reason why this could not change in the future but I wouldn't hold your breath for this happening in the short term.
That said, Objective-C and Swift really are not too scary...
2016 edit
Javascript with NativeScript framework is available to use now.
It seems this is now something developers are allowed to do: the iOS Developer Agreement was changed yesterday and appears to have been ammended in a such a way as to make embedding a Python interpretter in your application legal:
SECTION 3.3.2 — INTERPRETERS
Old:
3.3.2 An Application may not itself install or launch other executable
code by any means, including without
limitation through the use of a
plug-in architecture, calling other
frameworks, other APIs or otherwise.
Unless otherwise approved by Apple in
writing, no interpreted code may be
downloaded or used in an Application
except for code that is interpreted
and run by Apple’s Documented APIs and
built-in interpreter(s).
Notwithstanding the foregoing, with
Apple’s prior written consent, an
Application may use embedded
interpreted code in a limited way if
such use is solely for providing minor
features or functionality that are
consistent with the intended and
advertised purpose of the Application.
New:
3.3.2 An Application may not download or install executable code.
Interpreted code may only be used in
an Application if all scripts, code
and interpreters are packaged in the
Application and not downloaded. The
only exception to the foregoing is
scripts and code downloaded and run by
Apple’s built-in WebKit framework.
Yes you can. You write your code in tinypy (which is restricted Python), then use tinypy to convert it to C++, and finally compile this with XCode into a native iPhone app. Phil Hassey has published a game called Elephants! using this approach. Here are more details,
http://www.philhassey.com/blog/2009/12/23/elephants-is-free-on-the-app-store/
Yes, nowadays you can develop apps for iOS in Python.
There are two frameworks that you may want to checkout: Kivy and PyMob.
Please consider the answers to this question too, as they are more up-to-date than this one.
An update to the iOS Developer Agreement means that you can use whatever you like, as long as you meet the developer guidelines. Section 3.3.1, which restricted what developers could use for iOS development, has been entirely removed.
Source: http://daringfireball.net/2010/09/app_store_guidelines
Pythonista has an Export to Xcode feature that allows you to export your Python scripts as Xcode projects that build standalone iOS apps.
https://github.com/ColdGrub1384/Pyto is also worth looking into.
The iPhone SDK agreement is also rather vague about whether you're even allowed to run scripting languages (outside of a WebView's Javascript). My reading is that it is OK - as long as none of the scripts you execute are downloaded from the network (so pre-installed and user-edited scripts seem to be OK).
IANAL etc etc.
BeeWare is an open source framework for authoring native iOS & Android apps.
2019 Update:
While Python-iOS development is relatively immature and likely will prevent (afaik) your app from having native UI and functionality that could be achieved in an Apple-supported development language, Apple now seems to allow embedding Python interpreters in Native Swift/Obj-C apps.
This supports importing Python libraries and running Python scripts (even with supplied command-line arguments) directly from your Native Swift/Obj-C code.
My company is actually wrapping our infrastructure (originally written in Python) in a native iOS application! It works very well and communication between the parts can be easily achieved via a client-server model.
Here is a nice library by Beeware with a cookiecutter template if you want to try and run Python scripts in your iOS app: https://github.com/beeware/Python-Apple-support/tree/3.6.
Technically, as long as the interpreted code ISN'T downloaded (excluding JavaScript), the app may be approved. Rhomobiles "Rhodes" framework does just that, bundling mobile Ruby, a lightweight version of Rails, and your app for distribution via the app-store. Because both the interpreter and the interpreted code are packaged into the final application - Apple doesn't find it objectionable.
http://rhomobile.com/products/rhodes/
Even after the latest apple press release - rhodes apps (mobile ruby) are still viable on the app-store. I'd find it hard to believe that tinyPy or pyObjC wouldn't find a place if there is a willing developer community.
You can do this with PyObjC, with a jailbroken phone of course. But if you want to get it into the App Store, they will not allow it because it "interprets code." However, you may be able to use Shed Skin, although I'm not aware of anyone doing this. I can't think of any good reason to do this though, as you lose dynamic typing, and might as well use ObjC.
The only significant "external" language for iPhone development that I'm aware of with semi-significant support in terms of frameworks and compatibility is MonoTouch, a C#/.NET environment for developing on the iPhone.
I think it was not possible earlier but I recently heard about PyMob, which seems interesting because the apps are written in Python and the final outputs are native source codes in various platforms (Obj-C for iOS, Java for Android etc). This is certainly quite unique. This webpage explains it in more detail.
I haven't given it a shot yet, but will take a look soon.