Xpath 使链接描述指向IMPORTXML语句中的链接引用
我正在使用google sheets IMPORTXML函数抓取FINVIZ财务数据,具体如下:Xpath 使链接描述指向IMPORTXML语句中的链接引用,xpath,web-scraping,google-sheets,array-formulas,google-sheets-importxml,Xpath,Web Scraping,Google Sheets,Array Formulas,Google Sheets Importxml,我正在使用google sheets IMPORTXML函数抓取FINVIZ财务数据,具体如下: =IMPORTXML(“http://finviz.com/quote.ashx?t=“&B1,”//table[@id='news-table']/tr”) 针对以下来源: <table width="100%" cellpadding="1" cellspacing="0" border="0" id="news-table" class="fullview-news-outer">
=IMPORTXML(“http://finviz.com/quote.ashx?t=“&B1,”//table[@id='news-table']/tr”)
针对以下来源:
<table width="100%" cellpadding="1" cellspacing="0" border="0" id="news-table" class="fullview-news-outer">
<tr>
<td width="130" align="right" style="white-space:nowrap">Feb-15-20 03:58PM </td>
<td align="left"><a href="https://finance.yahoo.com/news/u-evacuate-citizens-quarantined-ship-043646253.html" target="_blank" class="tab-link-news">U.S. Woman From Cruise Falls Ill as 2,200 Head Home: Virus Update</a> <span style="color:#aa6dc0;font-size:9px">Bloomberg</span></td>
</tr>
<tr>
<td width="130" align="right">03:41PM </td>
<td align="left"><a href="https://www.marketwatch.com/story/afraid-of-sky-high-stock-valuations-consider-this-deep-value-strategy-2020-02-12?siteid=yhoof2&yptr=yahoo" target="_blank" class="tab-link-news">Afraid of sky-high stock valuations? Consider this deep value strategy</a> <span style="color:#aa6dc0;font-size:9px">MarketWatch</span></td>
</tr>
<tr>
<td width="130" align="right">10:47AM </td>
<td align="left"><a href="https://www.marketwatch.com/story/if-you-could-buy-only-one-stock-for-5g-and-artificial-intelligence-this-would-be-it-2020-02-14?siteid=yhoof2&yptr=yahoo" target="_blank" class="tab-link-news">If you could buy only one stock for 5G and artificial intelligence, this would be it</a> <span style="color:#aa6dc0;font-size:9px">MarketWatch</span></td>
</tr>
</table>
二月十五日至二十日下午三时五十八分
彭博社
下午3:41
市场观察
上午10:47
市场观察
因此,如果我选择Apple股票代码(AAPL),那么上面的IMPORTXML调用的XPATH组件将返回以下内容:
问题:如何修改XPATH组件以使新闻描述可单击到其HREF
我不希望URL替换新闻-只希望新闻指向其目的地,以便单击新闻将我带到链接。尝试:
=ARRAYFORMULA({INDEX(IMPORTXML("http://finviz.com/quote.ashx?t="&B1,
"//table[@id='news-table']/tr"),,1),
HYPERLINK(IMPORTXML("http://finviz.com/quote.ashx?t="&B1,
"//table[@id='news-table']/tr//a/@href"),
INDEX(IMPORTXML("http://finviz.com/quote.ashx?t="&B1,
"//table[@id='news-table']/tr"),,2))})
试试:
=ARRAYFORMULA({INDEX(IMPORTXML("http://finviz.com/quote.ashx?t="&B1,
"//table[@id='news-table']/tr"),,1),
HYPERLINK(IMPORTXML("http://finviz.com/quote.ashx?t="&B1,
"//table[@id='news-table']/tr//a/@href"),
INDEX(IMPORTXML("http://finviz.com/quote.ashx?t="&B1,
"//table[@id='news-table']/tr"),,2))})
真棒的家伙!非常感谢您的快速反馈!还有一个问题:下面截图中第2行的日期格式显示为15:41:00。我的,显示1899-12-30 03:41:00pm。我怎么才能让它只在日期的整数值小于1时显示时间呢?真是太棒了!非常感谢您的快速反馈!还有一个问题:下面截图中第2行的日期格式显示为15:41:00。我的,显示1899-12-30 03:41:00pm。我如何让它只在日期的整数值<1时显示时间,就像您所做的那样?