Google sheet 中的数据

Data in Google sheet

我尝试了以下公式来获取 pcr 数据...

=importxml("https://niftyinvest.com/put-call-ratio/MARUTI?expiry=30JUN2022","//span[@class='white-text red darken-1']"

对于不同的股票,这些值有 3 种不同的颜色 red/blue/green,具体取决于它们的预定义值。 如何获得通用公式,以便它可以检索任何颜色的数据????

其他数据链接...

1- https://niftyinvest.com/put-call-ratio/indigo?expiry=30jun2022

2- https://niftyinvest.com/put-call-ratio/britannia?expiry=30jun2022

3- https://niftyinvest.com/put-call-ratio/MARUTI?expiry=30JUN2022

对于 Pcr:

=INDEX(IMPORTXML(A2, 
 "//span[@class='white-text red darken-1'] | 
  //span[@class='white-text light-blue lighten-1'] |
  //span[@class='white-text green darken-1']"), 1)


对于 Intraday Pcr:

=INDEX(IMPORTXML(A2, 
 "//span[@class='white-text red darken-1'] | 
  //span[@class='white-text light-blue lighten-1'] |
  //span[@class='white-text green darken-1']"), 2)

尝试使用这个通用的 xpath //h5//span[@class[contains(.,'white-text ')]]

=transpose(importxml(A2,"//h5//span[@class[contains(.,'white-text ')]]"))

编辑:您可以使用查询对列重新排序并 select 按特定标准。

=QUERY(IMPORTHTML("https://niftyinvest.com/put-call-ratio/indigo?expiry=30jun2022","table",1),"select Col1,Col2,Col3,Col4,Col5,Col6,Col7 where Col4>0.6 and Col7>0.7 and Col1 <> 'IOC' and Col1 <> 'POWERGRID ' ")