2

I am trying to parse some data form a website but I just can't get it working.

I tried NDHpple, TFHpple, Kanna all of them without success.

I want to parse:

<td class="date">17:08</td>

And the XPath I get to it, using Firebug, is:

/html/body/section/div/section/article/div[1]/div[2]/div/table/tbody/tr[1]/td[1]

Right now I am using Kanna and my code is this:

@IBAction func btnLoadData(sender: NSButton) {

    if let doc = Kanna.HTML(url: (NSURL(string: "the_site_url")!), encoding: NSUTF8StringEncoding) {


        // Search for nodes by XPath
        for link in doc.xpath("/html/body/section/div/section/article/div[1]/div[2]/div/table/tbody/tr[1]/td[1]") {
            print(link.text)
            print(link["href"])
        }
    }
}

So, anyone can help me?

2
  • what exactly you want . 17:08? Commented Oct 15, 2015 at 7:20
  • @ShubhamJain Exactly. Commented Oct 15, 2015 at 7:21

1 Answer 1

1

It seemed that it wasn't not working because I was trying to load from a dynamic data webpage. I tried the same code and XPath with a static data webpage that has the same data I wanted to grab and it worked like a charm.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.