英文:
Updating data in an array pulled with importxml in google spreadsheet with another importxml
问题
I have an importxml code that fills in between the lines A3:A11 in google spreadsheet =IMPORTXML("https://www.enucuzgb.com/";"//tbody/tr/td[6]")
this code pulls price table from one site, from other sites. But since some of the prices on this site are not up to date, I draw the prices of those sites directly from that site. But I can't write the data I took in a line between A3:A11.
To summarize, the code above pulls the price list of 9 different sites, but since the prices of 2 sites are not up to date, I want to pull 2 sites separately.
Importxml formula that pulls data from 9 sites between A3:A11 (this formula is in cell A3);
=IMPORTXML("https://www.enucuzgb.com/";"//tbody/tr/td[6]")
Code in cell A9 that gets the price directly from a site;
=IMPORTXML("https://www.bursagb.com/knight-online-gb-c-4";"/html/body/div[1]/section[2]/div/div/div[2]/div[2]/div[3]/div[2]/button[2]")
The error given by the formula in A3 is "The result of the array is not expanded because it will overwrite the data in range A9."
(these formulas work every minute with google apps script and get current prices)
英文:
I have an importxml code that fills in between the lines A3:A11 in google spreadsheet =IMPORTXML("https://www.enucuzgb.com/";"//tbody/tr/td[6]")
this code pulls price table from one site, from other sites. But since some of the prices on this site are not up to date, I draw the prices of those sites directly from that site. But I can't write the data I took in a line between A3:A11.
To summarize, the code above pulls the price list of 9 different sites, but since the prices of 2 sites are not up to date, I want to pull 2 sites separately.
Importxml formula that pulls data from 9 sites between A3:A11 (this formula is in cell A3);
=IMPORTXML("https://www.enucuzgb.com/";"//tbody/tr/td[6]")
Code in cell A9 that gets the price directly from a site;
=IMPORTXML("https://www.bursagb.com/knight-online-gb-c-4";"/html/body/div[1]/section[2]/div/div/div[2]/div[2]/div[3]/div[2]/button[2]")
The error given by the formula in A3 is "The result of the array is not expanded because it will overwrite the data in range A9."
(these formulas work every minute with google apps script and get current prices)
答案1
得分: 2
Here are the translated parts of your content:
"从总结一下,上面的代码提取了9个不同网站的价格列表,但由于其中2个网站的价格不是最新的,所以我想单独提取这2个网站。
和A3中的公式给出的错误是“数组的结果没有扩展,因为它会覆盖范围A9中的数据。”
,我理解您期望的结果如下。
- 您希望将
=IMPORTXML("https://www.enucuzgb.com/","//tbody/tr/td[6]")
中的值1到6放入单元格“A3”。同时,您还希望将=IMPORTXML("https://www.bursagb.com/knight-online-gb-c-4";"/html/body/div[1]/section[2]/div/div/div[2]/div[2]/div[3]/div[2]/button[2]")
中的值放入单元格“A9”。
在这种情况下,以下修改如何?在此修改中,=IMPORTXML("https://www.enucuzgb.com/","//tbody/tr/td[6]")
的XPath已被修改。
从:
=IMPORTXML("https://www.enucuzgb.com/","//tbody/tr/td[6]")
到:
=IMPORTXML("https://www.enucuzgb.com/","//tbody/tr[position()<7]/td[6]")
-
请将此公式放入单元格“A3”。通过这样做,将检索值1到6。然后,您可以将第二个公式
=IMPORTXML("https://www.bursagb.com/knight-online-gb-c-4";"/html/body/div[1]/section[2]/div/div/div[2]/div[2]/div[3]/div[2]/button[2]")
放入单元格“A9”。 -
例如,如果您想检索值从4到9,请将XPath从
//tbody/tr[position()<7]/td[6]
修改为//tbody/tr[position()>3]/td[6]
。
测试:
使用上述公式时,将获得以下结果。
英文:
From To summarize, the code above pulls the price list of 9 different sites, but since the prices of 2 sites are not up to date, I want to pull 2 sites separately.
and The error given by the formula in A3 is "The result of the array is not expanded because it will overwrite the data in range A9."
, I understood your expected result as follows.
- You want to retrieve the values 1 to 6 from
=IMPORTXML("https://www.enucuzgb.com/","//tbody/tr/td[6]")
put into cell "A3". And also, you want to retrieve the value from=IMPORTXML("https://www.bursagb.com/knight-online-gb-c-4";"/html/body/div[1]/section[2]/div/div/div[2]/div[2]/div[3]/div[2]/button[2]")
put into cell "A9".
In this case, how about the following modification? In this modification, the xpath of =IMPORTXML("https://www.enucuzgb.com/","//tbody/tr/td[6]")
is modified.
From:
=IMPORTXML("https://www.enucuzgb.com/";"//tbody/tr/td[6]")
To:
=IMPORTXML("https://www.enucuzgb.com/","//tbody/tr[position()<7]/td[6]")
-
Please put this formula to cell "A3". By this, the values from 1 to 6 are retrieved. And, you can put your 2nd formula of
=IMPORTXML("https://www.bursagb.com/knight-online-gb-c-4";"/html/body/div[1]/section[2]/div/div/div[2]/div[2]/div[3]/div[2]/button[2]")
into cell "A9". -
For example, if you want to retrieve the values from 4 to 9, please modify xpath from
//tbody/tr[position()<7]/td[6]
to//tbody/tr[position()>3]/td[6]
.
Testing:
When the above formulas are used, the following result is obtained.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论