如何使用公式从Google表格中的链接提取网址? [英] How to extract URL from Link in Google Sheets using a formula?

查看:325
本文介绍了如何使用公式从Google表格中的链接提取网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从网站上复制了一系列超链接,并将它们粘贴到Google表格中。这些值显示为链接文本,而不是超链接公式,并且仍然正确链接。对于每一行,我尝试仅提取网址(不是友好文本)并将其插入相邻列。如何用公式完成这项工作?



例如:

  = SOMEFUNCTION(cellThatHoldsLink,returnedURLOnly)

这种和类似的情况不适用,因为粘贴的数据不是公式。
我会接受脚本(GAS)解决方案或任何解决方案,但宁愿使用公式来完成。我发现了几十个HYPERLINK操作脚本,但是在这种情况下甚至没有任何操作,甚至无法访问持有该URL的属性。感谢。

解决方案

您可以使用importxml提取整个数据表,并使用以下内容:

  = IMPORTXML(A1,// tr)

旁边我们拉入了标签中的url字符串

pre $ = IMPORTXML(A1, // tr / td [1] / a / @ href)

最后连接字符串原始域创建您的超链接

  = ARRAYFORMULA(http://www.bnilouisiana.com/& INDIRECT( A2:A& COUNTA(A2:A)))


I have copied from a website a series of hyperlinks and pasted them in a google sheet. The values show up as linked text, not hyperlink formulas, and are still linked correctly. For each row, I'm trying to extract the URL ONLY (not the friendly text) and insert it into the adjacent column. How could this be accomplished using a formula?

For example:

=SOMEFUNCTION(cellThatHoldsLink, returnedURLOnly)

This and similar scenarios do not apply because the pasted data are not formulas. I will accept a script (GAS) solution, or any solution for that matter, but would prefer if it could be done using a formula. I have found dozens of HYPERLINK manipulation scripts, but nothing on this particular scenario, or even how to access the property that is holding that url. Thanks.

解决方案

You can use importxml to pull in the whole data table and it's contents with this:

=IMPORTXML(A1,"//tr")

next to it we pulled in the url strings in the tags

=IMPORTXML(A1,"//tr/td[1]/a/@href")

and finally concatenated the strings with the original domain to create your hyperlinks

=ARRAYFORMULA("http://www.bnilouisiana.com/"&INDIRECT("A2:A"&COUNTA(A2:A)))

这篇关于如何使用公式从Google表格中的链接提取网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆