scinfu / SwiftSoup

SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS)
https://scinfu.github.io/SwiftSoup/
MIT License
4.52k stars 345 forks source link

Can’t scrap untagged html element #266

Open Flashby2 opened 6 months ago

Flashby2 commented 6 months ago

Hello,

I'm in a rather tricky situation because after numerous unsuccessful attempts and searches, I'm unable to retrieve the following element, which seems quite trivial. I'm trying to retrieve the string "2h43", but it doesn't seem to belong to any nodes. I've tried testing the outerHTML and the different siblings, but to no avail.

let html = "<strong><u>Durée</u> : </strong>02h43<br>"

Here's my line that should work:

let element: Element = try doc.select("strong:contains(Durée)").first()!

let durationText = try element.nextElementSibling()!.text()