M
M
MoscowRoller2021-08-24 14:44:31
Parsing
MoscowRoller, 2021-08-24 14:44:31

How do I use the importxml formula in google docs to parse my site's content with the same DIV classes?

Good day. Help, please, deal with the importxml function with unusual parameters.

Given: a page of my site (and about 500 similar ones).
Using the importxml functions, you need to upload the values ​​\u200b\u200bof the parameters (precisely the values) of the parameters: "make", "model", "Year", "Mileage" and so on into separate cells of google sheets .
At what stage I got stuck: I tried to transform this formula in every way, but stopped at this non-working option -

=importxml("https://anrimix.com/volkswagen-caddy-2018" , "//li[@class='odd']/div[@class='spec-name']/text('Пробег, км:')/div[@class='spec-value']")


What makes this whole thing complicated (that is, why don't I just use /div[1] and so on): the order (and generally the presence of certain fields) differs from page to page. Only the names of the fields remain unchanged (in the formula above, this is "Mileage, km:").

As a result, you need to get: the value of a certain field, defined by the div class by the condition of the name of this field. The field name is the only difference between div classes.

I am writing for the first time, if I violated some rules of formatting and wording of the question, as well as the traditions of the local community - do not hit hard, I will correct everything. He told, apparently, a little confusingly, but he is ready to comment on everything promptly. There are a lot of similar fields and similar pages, you can’t remake them with your hands, which means you need to learn new things).

PS do not offer to rewrite the structure of the site code and assign unique classes to each field, the admin did not appreciate the request.

Link to the file in the dock
Screen of the place in the code, for understanding the situation I enclose
6124dacb760b8617301351.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2021-08-24
@MoscowRoller

In this case, the XPath for the run looks like this:
//*[text()='Пробег, км:']/following-sibling::*[1]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question