I have a Google Sheet where rows are products and columns are information about these products (Material, Color, Price, ...).
These information are retrieved using the function IMPORTXML with the corresponding xpath query. In the following example, the column D is the URL of this product. These functions retrieve information (Glass, Color and Type) for the product on row 3:
=IMPORTXML(D3,"//table[@class='info-table']/tr[th/text()[contains(.,'Glass')]]/td")
=IMPORTXML(D3,"//table[@class='info-table']/tr[th/text()[contains(.,'Color')]]/td")
=IMPORTXML(D3,"//table[@class='info-table']/tr[th/text()[contains(.,'Type')]]/td")
For each product, there are around 10 columns that are retrieved and thus 10 different functions IMPORTXML for the same URL.
It works properly when there are few products but when there are too many products only some information is retrieved and the other cells stay frozen with the value "Loading...".
The only workaround I found is manually copy/pasting the retrieved values (Ctrl+C, Ctrl+Maj+v) and then some other cells are unblocked and start import the values. In the end, I need to do this for all cells and it takes a lot of time.
For example:
=IMPORTXML(D3,"//table[@class='info-table']/tr[th/text()[contains(.,{'Glass', 'Color', 'Type'})]]/td")
This issue can be fixed by adapting the xpath query and using a combination of different Google Spreadsheet formulas.
For example:
=TRANSPOSE(IMPORTXML(D2,"
(//table[@class='info-table']/tr[th/text()[contains(.,'Diameter')]]/td)[1] |
(//table[@class='info-table']/tr[th/text()[contains(.,'Material')]]/td)[1] |
(//table[@class='info-table']/tr[th/text()[contains(.,'Glass')]]/td)[1] |
(//table[@class='info-table']/tr[th/text()[contains(.,'W/R')]]/td)[1] |
(//table[@class='info-table']/tr[th/text()[contains(.,'Caliber')]]/td)[1] |
(//table[@class='info-table']/tr[th/text()[contains(.,'Type')]]/td)[1]"))
By doing so, there is only one importXML per product.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With