You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using 'SwiftSoup' SDK to parse HTMl content from UIWebView. I want the image size and resolution for each and every images fetched from HTML content. How to get the image size and resolution from HTML content received from SwiftSoup?
The text was updated successfully, but these errors were encountered:
Hi use CSS Selector to find your elements and select your attribute
func testIMGAttribute()throws {
let h = "<img src=\"img_girl.jpg\" alt=\"Girl in a jacket\" width=\"500\" height=\"600\">"
let doc = try SwiftSoup.parse(h)
let imgs: Elements = try doc.select("img[src]")
for img in imgs {
try print(img.attr("width"))
}
}
other example
func testSRC()throws {
let h = "<img src=\"img_girl.jpg\" alt=\"Girl in a jacket\" style=\"width:500px;height:600px;\">"
let doc = try SwiftSoup.parse(h)
let imgs: Elements = try doc.select("img[src]")
for img in imgs {
try print(img.attr("style"))
}
}
@purvimehta16 it's quite possible that the image size won't be in the HTML/CSS - you'll need to loop through all of the image tags, download them manually and see how big they are
Using 'SwiftSoup' SDK to parse HTMl content from UIWebView. I want the image size and resolution for each and every images fetched from HTML content. How to get the image size and resolution from HTML content received from SwiftSoup?
The text was updated successfully, but these errors were encountered: