例如,有什么方法可以从下面的链接下载 csv 文件。“https://www.nseindia.com/corporates-pit?index=equities&symbol=WABCOINDIA&csv=true”
尝试了下面的代码,但没有运气。
Private Declare PtrSafe 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
Public Sub Valuebuy()
myfile = "https://www.nseindia.com/corporates-pit?index=equities&symbol=WABCOINDIA&csv=true"
Dim targetFile As String, targetUrl As String, returnVal As Double
Target = "https://www.nseindia.com/api/corporates-pit?index=equities&symbol=WABCOINDIA&csv=true"
strSavePath = "C:\testdownload.txt"
returnVal = URLDownloadToFile(0, Target, strSavePath, 0, 0)
If returnVal = 0 Then
Debug.Print "Download ok!"
Else
Debug.Print "Error"
End If
End Sub