Until the website give me an access to his API, i need to display only 2 things from this website :
What i want to grab
// Example on a live page
Those 2 things are contained in a div :
<div style="float: right; margin: 10px;">
here what i want to display on my website
</div>
The problem is that i found an example on stackoverflow, but i never wrote preg_match before. How to do this with the data i want to grabb ? Thank you
<?php $html = file_get_contents($st_player_cv->getUrlEsl());
preg_match_all(
'What do i need to write here ?',
$html,
$posts, // will contain the data
PREG_SET_ORDER // formats data into an array of posts
);
foreach ($posts as $post) {
$premium = $post[1];
$level = $post[2];
// do something with data
}
The DOM way to do it would be
but there is a whole slew of JavaScript in the page that modifies the DOM heavily after the page was loaded. Since any PHP script based fetching will not execute any JavaScript, the style we search for in the XPath does not exist yet and we won’t get any results (the Regex suggesed by Hannes doesn’t work for the same reason). Neither do the level numbers on the badge exist yet.
As Wrikken pointed out in the comments, there also seems to be some mechanism to block certain requests. I had the message once, but I am not sure what triggers it, because I could also fetch page on several occasions.
To cut a long story short: you cannot achieve what you are trying to do with this page.