Skip to content
Advertisement

In VBA, How can we get data shown up with “Inspect Element”, but not with “View Page Source”?

I am trying to scrape a web page which includes multiple tabs. I want to get the quarterly data which is displayed when clicking on By-Quarter Tab, but my code keeps returning yearly data shown when clicking By-Year Tab. The problem is both types of data are on the same URL and when right-clicking “Inspect Element”, their IDs are also the same; you cannot distinguish the quarterly data element ID from yearly data data element ID. “Inspect Element” shows up both quarterlyand yealy data, but “View Page Source” shows up only yealy ones. Could anyone show me how to get the quarterly data please? Thank you very much.

JavaScript

End Sub


Links

  1. URL: https://s.cafef.vn/hose/VCB-ngan-hang-thuong-mai-co-phan-ngoai-thuong-viet-nam.chn

  2. Quaterly Data shown when clicking By-Quarter Tab https://drive.google.com/file/d/1oRtrBZxAoKgdE7gMSBsmkpSX_Ljv1c7L/view?usp=sharing

  3. Yearly Data shown when clicking By-Year Tab https://drive.google.com/file/d/1-tI5TU7IMOXFIhsfH8tGvsCRoB0O7Xl1/view?usp=sharing

  4. Inspect Quaterly Data: https://drive.google.com/file/d/1Xc5hRPTBIKFu7hQoLh4mStp92CxipNpU/view?usp=sharing

  5. Inspect yearly Data: https://drive.google.com/file/d/1LedAF3gvAYSIOKOKfZURR9A2rhK0SNgB/view?usp=sharing

Advertisement

Answer

One of the clues given is in the class where you see it says Ajax. This is dynamically added content. If you use the network tab of dev tools (F12), and manually select the quarterly tab, you will see the following request endpoint, which serves the data you are after:

https://s.cafef.vn/Ajax/Bank/BHoSoCongTy.aspx?symbol=VCB&Type=1&PageIndex=0&PageSize=4&donvi=1


JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement