Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

html - I'm having trouble downloading the file

The excel file, which previously had a fixed name, now appears with a different name every time I open the website. So I can't download the file anymore.

Here is the codes that I used before to download excel file,

Dim oXMLHTTP As Object, i As Long, vFF As Long, oResp() As Byte, vLocalFile As String, vWebFile As String
    'You can also set a ref. to Microsoft XML, and Dim oXMLHTTP as MSXML2.XMLHTTP
   
vLocalFile = Application.ActiveWorkbook.Path & "Tuik Endeksler.xls"
vWebFile = "https://data.tuik.gov.tr/Bulten/DownloadIstatistikselTablo?p=sMXVysuuaedLY7jqIqTRPTJjtNaSSk4bjfCMOy/B20bPEhOl94J1FV9NxZxg3phH"
   
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
oXMLHTTP.Open "GET", vWebFile, False 'Open socket to get the website
oXMLHTTP.Send 'send request

    'Wait for request to finish
Do While oXMLHTTP.readyState <> 4
    DoEvents
Loop

oResp = oXMLHTTP.responseBody 'Returns the results as a byte array

    'Create local file and save results to it
vFF = FreeFile
If Dir(vLocalFile) <> "" Then Kill vLocalFile
Open vLocalFile For Binary As #vFF
Put #vFF, , oResp
Close #vFF

Is there any way to download that file without referencing a file name. I'm not good at html controls.

Here is the link about excel file https://data.tuik.gov.tr/Kategori/GetKategori?p=Enflasyon-ve-Fiyat-106

At the rigth side of that page There is a header "?statistiksel Tablolar" The file is at line that has name "Yeni Yurt ??i üretici Fiyat Endeksi- B?lümlerin Toplam Endeks De?i?imine Etkisi (2003=100) NACE Rev.2"

This header ("Yeni Yurt ??i üretici Fiyat Endeksi- B?lümlerin Toplam Endeks De?i?imine Etkisi (2003=100) NACE Rev.2") is constant. So maybe it can be used instead file name in macro but I have no idea how can I do that.

Thanks for your help.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...