4

What's the formula to display an url in google sheet when part of said url is a variable from another cell?

I'll explain: in one cell I have this formula (used to scrape text with class 'description' in an html webpage, doesn't matter for the purpose of the question though) =importXML("http://www.xxx.it/code/9788823506183/doc/book.html","//span[@class='description']")

The numerical part changes everytime based on the value in another cell, say B3. Tried =importXML("http://www.xxx.it/code/(B3)/doc/book.html","//span[@class='description']") but of course it won't work.

Then I thought I could dinamically create the url in B2 and do like this: =importXML("B2","//span[@class='description']")

One step closer but I'm stuck anyway, how can I generate such url in B2? I can't find a suitable function in the docs. I could only come up with:

in A1 = 9788823506183

in B2 = http://www.xxx.it/code/("A1")/doc/book.html but it's not the correct syntax. :(

4

3 回答 3

2

在 Excel 中,您将执行以下操作。在谷歌电子表格中试一试。

=importXML("http://www.xxx.it/code/" & B3 & "/doc/book.html","//span[@class='description']")
于 2014-09-22T16:29:27.117 回答
1

CONCAT在 Google 表格中使用。

=CONCAT("http://www.xxx.it/code/(", $B2,")/doc/book.html")

您可能需要一个公式来获得字符串中的确切位置。

于 2015-10-29T22:24:01.663 回答
0

下面的示例基于单元格值启动计时器,但可以调整为从任何单元格值构建 URL。假设您要制作计时器的分钟数为 $C20

1) 制作一个构建 URL 第一部分的单元格,在我的例子中是 $E27:

=CONCAT(" https://www.google.com/search?q=set+timer+for+ ", $C20)

2) 创建第二个单元格来完成 URL,在我的例子中是 $E28:

=CONCAT($E27,"+分钟")

3)制作一个包含超链接的单元格,该超链接将调用计时器:

=HYPERLINK($E28, "为单元格值 C20 启动计时器")

然后,当您单击在#3 中创建的单元格时,将悬停一个超链接,您可以单击它。

于 2017-07-12T23:17:39.177 回答