WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

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!



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?


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.


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


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?



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.


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!


Hacking with Swift is sponsored by Emerge

SPONSORED Why are Swift reference types bad for app startup time, and what’s the performance cost of protocol conformances? That’s just a couple of the topics you can learn about on the Emerge blog — written by the app performance experts behind Emerge’s advanced app optimization and monitoring tools, based on their experience of working at companies like Apple, Airbnb, Snap, and Spotify.

Find out more

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.