I want to extract: 51.39%, from this website www.bayyinah.org
You can see the text just over the donate button 51.39% of $6 Million
This is the code that i am using to TRY get that value.
let task = NSURLSession.sharedSession().dataTaskWithURL(url!, completionHandler: { (data, response, error) -> Void in
if error == nil {
let urlContent = NSString(data: data!, encoding: NSASCIIStringEncoding) as NSString!
do {
// if encoding is omitted, it defaults to NSUTF8StringEncoding
let doc = try HTMLDocument(string: urlContent as String, encoding: NSUTF8StringEncoding)
// XPath queries
for element in doc.xpath("//*[@id='so_far']/text()") {
print(element)
}
} catch let error {
print(error)
}
}
})
task.resume()
}
The result that i am getting is:
0%
Thank you!