Find destination URL

ali_sh

New Member
Joined
Dec 15, 2019
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
Hello
When I use MSXML to search on a website, I can't extract the destination URL.
In using Internet Explorer I could easily use IEObj.LocationURL to have the url.
I know some websites create specific query type url but I have to use this code in many websites and need to know a general way to extract destination url.
I searched the whole internet but I didn't find the answer. I really need this so please let me know any ideas for this.
Thank you very much

VBA Code:
Sub test()

    Dim req As New XMLHTTP60
    Dim html As New HTMLDocument
    Dim reqBody As String
    
    req.Open "POST", "https://www.imdb.com/search/title", False
    req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    req.send "realm=title&title=john+wick&release_date-min=2018-01-01&genres=action"
    
    If req.Status = 200 Then
        html.body.innerHTML = req.responseText
    End If
    
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
What about using GET directly? The url in that case is of the base url and the payload
VBA Code:
Sub Test()
    Dim req As New XMLHTTP60, html As New HTMLDocument, sBaseURL As String, sPayload As String
    sBaseURL = "https://www.imdb.com/search/title"
    sPayload = "?title=john+wick&release_date=2018-01-01,&genres=action"
    With req
        req.Open "GET", sBaseURL & sPayload, False
        req.send
        If req.Status = 200 Then
            html.body.innerHTML = req.responseText
        End If
    End With
End Sub
 
Upvote 0
What about using GET directly? The url in that case is of the base url and the payload
VBA Code:
Sub Test()
    Dim req As New XMLHTTP60, html As New HTMLDocument, sBaseURL As String, sPayload As String
    sBaseURL = "https://www.imdb.com/search/title"
    sPayload = "?title=john+wick&release_date=2018-01-01,&genres=action"
    With req
        req.Open "GET", sBaseURL & sPayload, False
        req.send
        If req.Status = 200 Then
            html.body.innerHTML = req.responseText
        End If
    End With
End Sub

Thank you for your response. I didn't know I could use the get method for this site but I need a general way to obtain the new url for every website after searching and ...
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top