getdata__MSXML2.XMLHTTP

amo

Board Regular
Joined
Apr 14, 2020
Messages
80
Office Version
  1. 2010
Platform
  1. Windows
good afternoon friends
i am trying to get data using MSXML2.XMLHTTP
but it didn't work

any ideas?

VBA Code:
Sub getdata__MSXML


    Dim request As Object
    Dim response As String
    Dim html As New HTMLDocument
    Dim website As String
    Dim price As String
    Dim sht As Worksheet
    
    
    Application.DisplayAlerts = False
    Set sht = ActiveSheet
   
    
        On Error Resume Next
        website = "https://shopee.co.id/AFI-EC-Tshirt-Yumia-(LD-90-P-57)-i.10221730.5568491283"
        Set request = CreateObject("MSXML2.XMLHTTP")

request.Open "GET", website, False
request.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
request.send
response = StrConv(request.responseBody, vbUnicode)
html.DocumentElement.innerHTML = response

        
        price = html.querySelector("div.AJyN7v")(0).innerText
        
        Debug.Print price
        
        Application.StatusBar = ""
        On Error GoTo 0
    
Application.DisplayAlerts = True
End Sub

Thank you for your help
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

RickXL

MrExcel MVP
Joined
Sep 9, 2013
Messages
4,328
Hi,

Unfortunately, it may never work.

It looks to me as if the web page is rendered on the client side using JavaScript. Simplifying, that means that the data you get from the server is just a set of Java calls and the full content of the page is determined by the client. For instance, if I use my browser to look at the source code it looks completely different from what it looks like in the browser developer tools after the page has been rendered.

I am told that the solution you need uses either something called Selenium or an API,

Sorry.
 

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,300
Office Version
  1. 2010
Platform
  1. Windows
this question has been asked several times with different thread headings.
i have looked at the site. it has a bucket of cookies to manage and the only easy way is to use browser automation which can manage all the stuff going on. selenium a good choice, but i dont use it.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,905
Messages
5,638,911
Members
417,058
Latest member
BRYCEPIETROWIAK

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
Top