• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy items from dropbox

Not yet. As soon as there is an update, you will be the first to know. It seems I'm very close. I've got it working with python but in vba it's hard to deal with cookies and i have not much knowledge about creating a session and reuse it. Moreover, I haven't got anything richer other than what I've learnt from sir Chihiro and Marc L when it is about playing with asp.net sites.
 
So what is it that you want to do? Download files? Or just extract url for each file?

FYI - The reason your copied text is different from inspection is that immediate window has limit on how many line of text it retains. Instead use FreeFile to write response to text.

Something like...
Code:
Sub dropbox_info()
    Dim http As New XMLHTTP60, str_items As Variant
    Dim oPath As String: oPath = "C:\Test\drop1.txt"
    Dim intFF As Integer: intFF = FreeFile()
    With http
        .Open "GET", "https://www.dropbox.com/sh/v4zcawgs32v7qc9/AAALfDRjpNOT8NnOTL_4XAXja?dl=0", False
        .send
        str_items = .responseText
    End With
    Open oPath For Output As #intFF
    Print #intFF, str_items
    Close #intFF
End Sub
 
Something like below then.
Code:
Sub dropbox_info()
    Dim http As New XMLHTTP60, str_items As Variant
    Dim oPath As String: oPath = "C:\Test\drop1.txt"
    Dim m As Object, mymatches As Object
    With http
        .Open "GET", "https://www.dropbox.com/sh/v4zcawgs32v7qc9/AAALfDRjpNOT8NnOTL_4XAXja?dl=0", False
        .send
        str_items = .responseText
    End With
    With CreateObject("VBScript.RegExp")
        .Pattern = "(url\"": \"")(https:\/\/www.dropbox.com\/sh\/.{1,99})(\"", \""ownerName)"
        .Global = True
        Set mymatches = .Execute(str_items)
        For Each m In mymatches
            Debug.Print m.SubMatches(1)
        Next
    End With
End Sub
Note: You may want to exclude first match to above since it's url for the folder and not file.
 
Last edited:
That's exactly what I was seeking for. You are awesome Chihiro
I really love your great solution

Best and Kind Regards
 
Via VBA basics text functions like any beginner must do :​
Code:
Sub DemoReq()
    With CreateObject("WinHttp.WinHttpRequest.5.1")
        .Open "GET", "https://www.dropbox.com/sh/v4zcawgs32v7qc9/AAALfDRjpNOT8NnOTL_4XAXja?dl=0", False
        .setRequestHeader "DNT", "1"
        On Error Resume Next
        .send
    If .Status = 200 Then V = Split(.responseText, """filename"": """)
        On Error GoTo 0
    End With
    If IsArray(V) Then
        For N& = 1 To UBound(V) - 1
            Debug.Print N; ": "; Split(V(N), """")(0); vbLf; Tab(6); Split(Split(V(N), """href"": """)(1), """")(0)
        Next
    End If
End Sub
As it's just about R E A D I N G ‼ …
 

No magic neither wonder : it's just a beginner way as shown
in many threads of this forum and even in any other forum !
Just with an easy search, just reading VBA inner help or any tutorial …
 
No as this sample is just extracting text part with VBA basics
like any beginner must do (see InStr and Mid in VBA inner help)
requiring logic at child level, yet shown in several of your own threads !

Chihiro post #34 is more « awesome » using a regular expression
requiring middle to advanced level …

Anyway thanks folks !
 
What is still unclear to me is that if the items (files and urls) can be parsed from that site using split on responsetext property, then why not I could do the same using tag name or class name.
 
Chihiro post #32 shows how to save responseText to a text file.
Then it's nothing but reading this text
just opening this file within Notepad and observing
where text to extract stands, what is just before and
just after in order to cut it between those delimiters, not difficult …
Nothing else than yet explained in post #21
as from beginning you just must read & search within this text !

If a class name appears in this text file
- or just test if exists within responseText via Instr -
so you are able to grab data using a DOM like htmlfile

If not, probably a script update during browsing,
so only via a DOM from a browser like Internet Explorer …
 
Back
Top