Questions tagged [swiftsoup]

a Swift HTML Parser library for working with real-world HTML through a convenient API for extracting and manipulating data using DOM, CSS, and jquery-like methods.

SwiftSoup is a pure Swift HTML Parser library for working with real-world HTML. It provides a convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods. SwiftSoup implements the WHATWG HTML5 specification, parsing HTML to the same DOM as modern browsers do.

Main features:

  • Scrape and parse HTML from a URL, file, or string
  • Find and extract data, using DOM traversal or CSS selectors
  • Manipulate HTML elements, attributes, and text
  • Sanitizing: Clean user-submitted content against a white-list, to prevent XSS attacks
  • Deal with all varieties of HTML found in the wild; from validating to invalid tag-soup
  • Output tidy HTML

SwiftSoup is available through CocoaPods, Carthage, and on GitHub.

For further information and documentation see

Author: Nabil Chatbi, scinfu@gmail.com
Note: SwiftSoup was ported to Swift from Java Jsoup library.

License: SwiftSoup is available under the MIT license.

53 questions
5
votes
1 answer

Jsoup: wrap text belonging to body in a div?

I have an html string that looks something like this: I am a text that needs to be wrapped in a div!
...
... I am more text that needs to be wrapped in a div! ... So I need to wrap that dangling html text in…
Lucas P.
  • 4,282
  • 4
  • 29
  • 50
3
votes
1 answer

How to get Api access in Swift?

I have created a program in python where I scrape a value from a 'wind' website. Everything works OK, but I wanted to try to build the same app in Swift, but when I try to run the program, it gives this error: "Unauthorized API access!" But scraping…
surftijmen
  • 743
  • 1
  • 10
  • 27
3
votes
1 answer

How can I use SwiftSoup to scrape a particular website that redirects?

I am trying to make Swift scrape websites using SwiftSoup. However, websites like: https://apple.news/AQZXxg8mUQfKrEaM9MRBpxw , it redirects automatically using JavaScript which causes SwiftSoup to scrape the opening page instead of the actual…
WannaInternet
  • 327
  • 1
  • 6
  • 14
3
votes
0 answers

Memory use increases with every call to function - Swift

I've got a method which uses swift's String(contentsOf: ... function to pull data off a website asynchronously several times in a row. Using the SwiftSoup library, I'm able to parse data from the HTML. This data is then stored into an array of…
Rstew
  • 585
  • 2
  • 9
  • 21
2
votes
0 answers

How can I change
tag with line break in SwiftSoup?

I'm trying to get a paragraph with SwiftSoup, the html has the codes. When I parse it, it's just getting text without line break. How can I change tags with line breaks? do { let html = "First parse" +…
Emre Isik
  • 51
  • 6
2
votes
1 answer

Parse HTML with Swiftsoup (Swift)?

I'm trying to parse some websites with Swiftsoup, let's say one of the websites is from Medium. How can I extract the body of the website and load the body to another UIViewController like what Instapaper does? Here is the code I use to extract the…
Vincent
  • 486
  • 6
  • 20
2
votes
1 answer

Find & Replace String using regex

I need to extract data from a string which is returned from a website with POST request; I am parsing the data with SwiftSoup library. I have selected the list items using a CSS selector: let iconsList: Element = try…
Atlas_Gondal
  • 2,512
  • 2
  • 15
  • 25
1
vote
1 answer

Swift how can I make this function async to get rid of my application warning

I am using SwiftUI 4.0 and have the SwiftSoup package . When I try to load a website I now get this message (happens for any website) Synchronous URL loading of https://www.cnn.com should not occur on this application's main thread as it may lead…
user1591668
  • 2,591
  • 5
  • 41
  • 84
1
vote
0 answers

how to save data from webcrawlling by date, mealtype

As you can see in this screenshot, I want to save those Korean-written data in array. (actually they are food menu of my dormitory)
이원석
  • 13
  • 4
1
vote
2 answers

url data task is not showing the right content when parsed with SwiftSoup? Swift 5

I am pretty new to swift and have an app that performs a simple url data task to parse the html contents of that website. I was trying to load certain elements but wasn't getting the content that I was seeing on the website when I inspect it…
1
vote
1 answer

SwiftSoup - Extracting specific div tags/elements

I'm not the most knowledgeable when dealing with scraping/getting data from a website, so apologies in advance. I have loaded in the HTML file locally, into my project so that I can have a reference and breakdown of the elements:
SwiftUser
  • 555
  • 6
  • 17
1
vote
1 answer

Parsing table data from HTML retrieved from web

Right now in my code I have retrieved HTML from a baseball website that displays the stats of a roster of players. There are multiple tables in the HTML and I only want the data from the one posted below. I'm not sure how to parse only that table…
pigsploof
  • 35
  • 6
1
vote
0 answers

SwiftSoup wrap text in body to a div

I have a HTML that I would like to manipulate with SwiftSoup but I have no idea how to wrap the texts inside body with a div Here's an example input: text not in a div
text already in a div
The output I would like…
Winson Lam
  • 11
  • 1
1
vote
1 answer

How to parse html table data to array of string in swift?

I'm developing an iOS app in which I need to parse HTML from a link with the swiftsoup library. I have done it. But it shows all the table data as a string. I need to get separate data which should be stored in separate arrays. Here is the table: …
Md Khairul Islam
  • 597
  • 5
  • 14
0
votes
0 answers

SwiftSoup Parsing HTML issue

I am building an IOS app where I search for specific keyword in google and then parsing the HTML data using SwiftSoup as string and then extracting the data I want from that string , everything work good but the problem is that for some key words…
1
2 3 4