UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How to connect Python scripts to SwiftUI

Forums > iOS

Hello all,

I'm trying to create my own news reader app, like Pocket or Instapaper, and I have used the Python library, Beautiful Soup, to scrape the data after a URL is provided. How do I embed this functionality into my app?

I found this somewhat related discussion but it's not exactly what I'm seeking.

I know there is SwiftSoup, but I'm trying to learn how to use Python libraries because they offer a lot more functionality and most APIs have Python docs which I plan to use in the future.

Could anyone point me in the right direction?

Thank you!

3      

Hi,

well, as a first step I would research how to run Python code inside iOS app. This should be possible since there is popular app Pythonista which is Python IDE for iOS. After that is done, you need a way to send data between Python and Swift.

Maybe try this - https://github.com/pvieito/PythonKit?

4      

Thank you! I'm looking into PythonKit.

Would you know/guess how Pocket or Instapaper implement scraping + parsing in their their iOS apps? Instapaper used to have an API, but this has since been deprecated.

3      

I think these are mainly "client" apps meaning all the logic is somewhere on the server where it can be used for iOS, Android and web versions. When you add article to Pocket iOS app it most likely sends the link to the server, servers does the parsing and sends back parsed article.

If you are interested you can check out the app Charles and monitor, how apps on your phone "talk" to the servers

4      

Oh right! Do you mean this is accomplished using a server-side component like those available via AWS EC-2 or Google's app engine?

https://www.dummies.com/web-design-development/ios/adding-a-server-side-component-to-your-mobile-app/

3      

I don't know, maybe, maybe something custom which is more likely. That being said you can totally do this locally on iOS device, there is no technical limitation.. Especially if you don't plan Android or web version, then server loses these benefits.

4      

Cool cool. After some research, Alamofire, Perfect-CURL, and Vapor will help a lot when with dealing APIs, and server side apps. Thank you, Filip!

4      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.