NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

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!

   

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?

1      

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

1      

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/

   

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.

1      

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!

1      

Hacking with Swift is sponsored by Fernando Olivares

SPONSORED Would you describe yourself as knowledgeable, but struggling when you have to come up with your own code? Fernando Olivares has a new book containing iOS rules you can immediately apply to your coding habits to see dramatic improvements, while also teaching applied programming fundamentals seen in refactored code from published apps.

Try the book!

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

Reply to this topic…

You need to create an account or log in to reply.

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.