使用 Excel VBA 下载 SEC 文件 - 内联 XBRL 查看器问题
Download SEC filings using Excel VBA - Inline XBRL viewer issue
我正在尝试使用 Excel vba 从 SEC 网站下载 SEC 文件(10-K、8-K 等)。我正在使用 getelementsbytagname 来识别归档的 url。但是,当我使用 "URLDownloadToFile" 私有函数时,我无法下载文件,而是得到不包含任何归档文本的 "Inline XBRL Viewer.htm" 文件。下面是我正在使用的代码:
htmlCol3 = htmlDoc1.getElementsByTagName("a")
For Each htmlInput3 In htmlCol3
If Left$(htmlInput3, 36) = "https://www.sec.gov/ix?doc=/Archives" Then
URL1 = Trim(htmlInput3)
buf = Split(URL1, ".")
ext = buf(UBound(buf))
If dt >= rptdt Then
strSavePath = FOL & "\" & CIK & "_" & FIL & "_" & str1 & "." & ext
ret = URLDownloadToFile(0, URL1, strSavePath, 0, 0)
下面是我使用的下载文件功能:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _
szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
我正在尝试从该网页顶部 table 的文档列中获取第一个 url:
https://www.sec.gov/Archives/edgar/data/769397/000076939719000016/0000769397-19-000016-index.htm
要获得实际的文件,去掉 ix?doc=
位,这样你就有一个 URL 开始 https://www.sec.gov/Archives/...
例如
URL1 = Replace(URL1, "https://www.sec.gov/ix?doc=", "https://www.sec.gov")
我正在尝试使用 Excel vba 从 SEC 网站下载 SEC 文件(10-K、8-K 等)。我正在使用 getelementsbytagname 来识别归档的 url。但是,当我使用 "URLDownloadToFile" 私有函数时,我无法下载文件,而是得到不包含任何归档文本的 "Inline XBRL Viewer.htm" 文件。下面是我正在使用的代码:
htmlCol3 = htmlDoc1.getElementsByTagName("a")
For Each htmlInput3 In htmlCol3
If Left$(htmlInput3, 36) = "https://www.sec.gov/ix?doc=/Archives" Then
URL1 = Trim(htmlInput3)
buf = Split(URL1, ".")
ext = buf(UBound(buf))
If dt >= rptdt Then
strSavePath = FOL & "\" & CIK & "_" & FIL & "_" & str1 & "." & ext
ret = URLDownloadToFile(0, URL1, strSavePath, 0, 0)
下面是我使用的下载文件功能:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _
szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
我正在尝试从该网页顶部 table 的文档列中获取第一个 url:
https://www.sec.gov/Archives/edgar/data/769397/000076939719000016/0000769397-19-000016-index.htm
要获得实际的文件,去掉 ix?doc=
位,这样你就有一个 URL 开始 https://www.sec.gov/Archives/...
例如
URL1 = Replace(URL1, "https://www.sec.gov/ix?doc=", "https://www.sec.gov")