how to echo a website page in php that has js file in it

Dotizo :

There is a site that is https://tse.ir/MarketWatch.html

i know that i have to use

file_get_contents("https://tse.ir/MarketWatch.html")

to get the html part of site, but how can i find specific part of site for example like this part in text file

<td title="دالبر" class="txt namad">دالبر</td>

cause when i open the text file, i never see this part, i think it is for that in website there is js file, how can i get all information of website that include every part i want? thank you very much

nklen :

Content loaded by ajax request via javascript. This means you can't get this data simply grabbing the page contents.

There are two ways of collecting data you need:

  1. Use solution based on selenium webdriver to load this page by real browser (which will execute JS), and collect data from rendered DOM.
  2. Research what kind of requests are sent by website to get this data. You could use network activity tab in browser dev tools. Here is example for chrome. For other browsers is the same or similar. Than you send the same request and pase response regarding to your needs.

In your specific case, probably, you could use this url: https://tse.ir/json/MarketWatch/data_1.json to accees the json object with data you need.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=12020&siteId=1