how to scrap text from web in swift?

I am trying to create an application whaich will show some text data related to events in educational insitutions.Can you suggest me any latest tutorial or can give me some simple code..

Swift is not really the best choice for such a task. I suggest Python or Perl.

This is very tricky in the general case. The problem is that web page content can be generated dynamically, so you can’t just fetch the web page with a networking API and then parse the resulting HTML (and, to be clear, parsing HTML is tricky in and of itself). The best option, again in the general case, is to load the page in a web view and then run JavaScript in the web view to return the content you’re interested in.

However, in any given specific case this could be quite straightforward. To choose an example at random (actually, I was showing this to my kids yesterday as part of me talking to them about regular expressions), if you were trying to find all the download links in the Darwin open source page you’ll see that the structure makes it very easy. You could fetch the page with URLSession and then do a regex search for

[-/.a-z0-9]+\.tar\.gz
.

If you post an example of what the web page looks like, we may be able to offer you more concrete advice.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Can we use python or perl in iphone application? I will really appreciate this if you can guide me on this as well.

Sir actually i am trying to fetch data l from highlight section of this website http://iiu.edu.pk/default.htm

You might be better off following the More link, which brings you to this page, which has a more straightforward structure. You can fetch that page with URLSession and then treat the HTML as text and parse out the relevant chunks. The drawback with that approach is that it’s going to be very brittle. Even a small change to the web page’s structure will break your app.

Have you thought about asking the site admins to set up an API (or even an RSS feed) for this content? That’s likely to make your app much more reliable in the long term.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I think you probably could. You would have to compile an embedded version. It would be an interesting exercise, but probably not worth your time. Why does it have to be an iPhone application though? You could write an online web scraper using all the scraping packages that exist for Python or Perl (likely to be in the hundreds). Then just feed the collected data to your iPhone app via more traditional means. Then, if one of those sites changes its data, your app isn't broken. You could either update the online scripts for have a fallback for a manual update of the data until you fix the scipts. If you a doing web scraping, redoing your scripts will be a regular occurence.

how to scrap text from web in swift?
 
 
Q