1
1
1ndrei2018-03-02 16:49:31
JavaScript
1ndrei, 2018-03-02 16:49:31

How to parse identical elements on a web page (perhaps via xpath or some other way)?

It can be very useful to parse the same elements on the page: phone numbers, some headings, something else.
This can be done via xpath. Or, for example, through google spreadsheet through the importxml formula, which works with xpath.
But through spreadsheet it is not always convenient and possible.
Is there any plugin that does this.
Entered xpath - he immediately gave you all the elements that matched the request.
Perhaps something similar exists, but in other ways - through js, for example.
Like, getelements by id - and it gives you all these elements in plain text.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
1
1ndrei, 2018-03-03
@1ndrei

Through selectors:
z=''; $$('h3').forEach(function(i){z += i.innerText+'\n'}); copy(z)
Via xpath:
z=''; $x('//h3').forEach(function(i){z += i.innerText+'\n'}); copy(z)
The result, in the buffer is a neat list of what you need.

S
Sergey Karakulov, 2018-03-02
@zero-cool

If I understand correctly, but I think you can get by with just a javascript script.
for example, this code displays in the console, in text format, the menu items of the "Toaster"
We got a collection of html elements, and for each element of the collection we called the callback function, which displays its content (innerHTML) .
Naturally, you can write some kind of universal script; And maybe even if you need to arrange it as a plugin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question