0

I have written a Jsoup class file to scrape a page and grab the hrefs for every element on the page. What I would like to do from there is to extract the Xpath for each of the elements from their hrefs.

Is there a way to do this in JSoup? If not is what is the best way to do this in Java (and are there any resources on this)?

Update

I want to clarify my question.

I want to scan a page for all the href identifiers and grab the links (that part is done). For my script, I need to get the xpath of all the elements I have identified and scraped from the (scanned) page.

The problem is that I assumed I could easily translate the href links to Xpath.

halfer
  • 19,824
  • 17
  • 99
  • 186
ironmantis7x
  • 807
  • 2
  • 23
  • 58
  • 1
    you want to extract text inside the href link , say `testing` link and you need `testing` from it? or clarify little more about the xpath and the actual thing you need? – Rishal Oct 05 '16 at 20:05
  • @Rishaldevsingh i want to scan a page for all the href identifiers and grab the links (that part is done). for my script I need to get the xpath of all the elements i have identified and scraped from the page. I assumed i could easily translate the href links to xpath. I need some help on this... – ironmantis7x Oct 06 '16 at 13:55
  • i am really not great with xpath but if you clarify exactly what you need then it should be great for all the people. show us something that this the thing you have done and now this is the part where you are stuck. – Rishal Oct 06 '16 at 15:56
  • 1
    [http://stackoverflow.com/questions/7085539/does-jsoup-support-xpath](http://stackoverflow.com/questions/7085539/does-jsoup-support-xpath) check this link if this is what u need – Rishal Oct 06 '16 at 16:27

1 Answers1

0

The comment from @Rishal dev Singh ended up being the right answer. Check his link here: http://stackoverflow.com/questions/7085539/does-jsoup-support-xpath

ironmantis7x
  • 807
  • 2
  • 23
  • 58