1
votes

I need a some help in getting a ImportXML command to return the result I'm looking for. I'm using Google Sheets. This is the website: https://www.foresteu.com/butorajtok-es-tartozekaik/tomorfa/trieste/10000520000-tomorfa-trieste-116x146mm-mez

This xpath works, but it is way too long: //div[contains(@class, 'col-xs-120 nopad')]/div[contains(@class, 'col-xs-120 nopad')][2] | //div[contains(@class, 'col-xs-120 nopad')]/div[contains(@class, 'col-xs-120 nopad')][3] | //div[contains(@class, 'col-xs-120 nopad')]/div[contains(@class, 'col-xs-120 nopad')][4] | //div[contains(@class, 'col-xs-120 nopad')]/div[contains(@class, 'col-xs-120 nopad')][5] | //div[contains(@class, 'col-xs-120 nopad')]/div[contains(@class, 'col-xs-120 nopad')][6] | //div[contains(@class, 'col-xs-120 nopad')]/div[contains(@class, 'col-xs-120 nopad')][7]

Can i make it shorter? I can't find a shorter xpath which works.

1
Did my answer show you the result what you want? Would you please tell me about it? That is also useful for me to study. If this works, other people who have the same issue with you can also base your question as a question which can be solved. If you have issues for my answer yet, feel free to tell me. I would like to study to solve your issues. - Tanaike
@Tanaike it works, thank you very much for your help. Selected as answer! - István Bálinth
Thank you for your response. I'm glad your issue was solved. Thank you, too. - Tanaike

1 Answers

0
votes

How about this xpath? I think that there might be more simple xpath. So please think of this as one of several answers.

Modified xpath:

//div[@class='col-xs-120 nopad'][./span]
  • https://www.foresteu.com/butorajtok-es-tartozekaik/tomorfa/trieste/10000520000-tomorfa-trieste-116x146mm-mez is put in "A1".
    • Formula is =IMPORTXML(A1,"//div[@class='col-xs-120 nopad'][./span]")
  • //div[@class='col-xs-120 nopad'] means div that class is col-xs-120 nopad.
  • [./span] means div which have span under div.

Result:

enter image description here

If this was not what you want, I'm sorry.