更新数据时在 Power BI 中使用 Yahoo Finance 时出现身份验证错误

Authentication error using Yahoo Finance in Power BI when updating data

当尝试使用 Yahoo Finance link 从 csv 文件自动更新股票价值时,使用这个:

Source = Csv.Document(
    Web.Contents(
      "https://query1.finance.yahoo.com/v7/finance/download/"
        & Comp
        & "?period1=1022112000&period2="
        & LastDate
        & "&interval=1d&events=history"
    ), 
    [Delimiter = ",", Columns = 7, Encoding = 1252, QuoteStyle = QuoteStyle.None]

补充说明:comp和lastdate为自定义参数,其中comp获取所有公司股票数据,lastdate记录最近的股票日期。

每次尝试使用匿名或用户登录访问数据时,我总是收到身份验证错误。我能做什么?

谢谢

请检查您为 URL 字符串提供的值。可能有一些错误。

你可以用函数检查这个例子:

let
    Source = (STOCKNAME, StartDat, EndDat) => let
            Source = Csv.Document(Web.Contents("https://query1.finance.yahoo.com/v7/finance/download/"&STOCKNAME&"?period1="&StartDat&"&period2="&EndDat&"&interval=1d&events=history&includeAdjustedClose=true"),[Delimiter=",", Columns=7, Encoding=1252, QuoteStyle=QuoteStyle.None]),
            #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
            #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type date}, {"Open", type text}, {"High", type text}, {"Low", type text}, {"Close", type text}, {"Adj Close", type text}, {"Volume", Int64.Type}})
        in
            #"Changed Type"
in
    Source

查询:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCgkPCVLSUTI0M7E0MzY1MjCAcsyNDM2AnFidaCVPvxBnVFEIx8LAwgCkJBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [TICKER = _t, Start = _t, End = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"TICKER", type text}}),
    #"Invoked Custom Function" = Table.AddColumn(#"Changed Type", "GetStock", each GetStock([TICKER], [Start], [End])),
    #"Expanded GetStock" = Table.ExpandTableColumn(#"Invoked Custom Function", "GetStock", {"Date", "Open", "High", "Low", "Close", "Adj Close", "Volume"}, {"GetStock.Date", "GetStock.Open", "GetStock.High", "GetStock.Low", "GetStock.Close", "GetStock.Adj Close", "GetStock.Volume"})
in
    #"Expanded GetStock"