[英]Google Sheets IMPORTXML query
I'm using Google Sheets as web scraper. 我正在将Google表格用作网络抓取工具。
I have been using this IMPORTXML 我一直在使用这个IMPORTXML
=importxml(A1, "//div[@class='review-content']//text()")
and this is the results 这就是结果
Row1: {"publishedDate":"2019-01-05T22:19:28Z","updatedDate":"null","reportedDate":"null}
Row2: {"publishedDate":"2018-12-10T22:19:28Z","updatedDate":"null","reportedDate":"null}
Row3: {"publishedDate":"2018-12-09T22:19:28Z","updatedDate":"null","reportedDate":"null}
but am having trouble figuring out how to get only the "publishedDate" value. 但在弄清楚如何仅获取“ publishedDate”值时遇到了麻烦。 Example:
例:
Row1: 2019-01-05T22:19:28Z
Row2: 2018-12-10T22:19:28Z
Row3: 2018-12-09T22:19:28Z
Any ideas as to what I may be missing 关于我可能缺少的任何想法
How about these 3 samples? 这三个样本怎么样? I thought them from the samples of your question.
我从您问题的样本中想到了它们。 I think that there are several answers for your situation.
我认为您的情况有几个答案。 So please think of this as 3 samples of them.
因此,请将此视为其中的3个样本。
It supposes that the URL is put in the cell "A1". 假定URL放在单元格“ A1”中。
=ARRAYFORMULA(MID(IMPORTXML(A1, "//div[@class='review-content']//text()"),19,20))
MID()
. MID()
检索。 =ARRAYFORMULA(INDEX(SPLIT(IMPORTXML(A1, "//div[@class='review-content']//text()"),"""",TRUE,TRUE),,4))
SPLIT()
and INDEX()
. SPLIT()
和INDEX()
检索。 =ARRAYFORMULA(REGEXEXTRACT(IMPORTXML(A1, "//div[@class='review-content']//text()"),"publishedDate"":""(\w.+?)"""))
REGEXEXTRACT()
. REGEXEXTRACT()
检索。 If these were not the results you want, I apologize. 如果这些不是您想要的结果,我深表歉意。 At that time, in order to correctly replicate your situation, can you provide the URL you are using as @Rubén says?
那时,为了正确地复制您的情况,您能否按照@Rubén的说明提供所使用的URL?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.