36

I am trying to grab the score table from a website. The problem is that the site is using javascript that apparently loads on document.ready.

For that reason I don't seem to succeed getting the table and all I get is the buttons at the top of that page.

Any suggestions or ideas on how to solve this?

2

2 Answers 2

30

cURL will only get you the markup of the page. It won't load any additional resources or process the page. You probably want to look at something like PhantomJS for this. PhantomJS is a headless WebKit browser. It has its own API that lets you "script" behavior. So you can tell PhantomJS to load the page and dump out the data you need.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer. I will need to run this as JavaScript and then save the dump to a PHP variable using the exec command. Is that correct?
You don't have to, actually. You can run it directly from the command line. But if you are using this to display it on a website, then yes you can use exec from PHP.
6

Depending on what exactly you're trying to do, you could just fetch the JSON data that makes the table:

http://www.opap.gr/web/services/rs/betting/availableBetGames/sport/program/4100/0/sport-1.json?localeId=el_GR

3 Comments

Thanks for your answer. I will mark Vivins answer as the answer to my question but yours was also really good. I wonder how did you find the json call?
@m33ts4k0z: No problem. I found it by using the "Network" tab of Chrome's Developer Tools (The same is possible in other browsers as well). Since document.ready was involved I guessed that the page probably loaded the information externally.
@PradeepKumarPrabaharan 3 years later LOL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.