How to get counter value from ebay
hi there.
I am desperatly trying to get the counter value from ebay-kleinanzeigen but it cant get it working.
Any Idea?
the output is:
but there is the value missing?
for example :
How can I get it?
thanks you in advance.
I am desperatly trying to get the counter value from ebay-kleinanzeigen but it cant get it working.
Any Idea?
<html>
<head>
<title>Counter value</title>
</head>
<body>
<?php
$url = "https://www.ebay-kleinanzeigen.de/s-615080998/k0";
$content = file_get_contents($url);
$first_step = explode( '<div id="viewad-cntr" class="textcounter">' , $content );
$second_step = explode("</div>" , $first_step[1] );
echo $second_step;
?>
</body>
</html>
the output is:
<span id="viewad-cntr-num"></span>
but there is the value missing?
for example :
<span id="viewad-cntr-num">00004</span>
thanks you in advance.
Please also mark the comments that contributed to the solution of the article
Content-Key: 331880
Url: https://administrator.de/contentid/331880
Printed on: April 19, 2024 at 19:04 o'clock
6 Comments
Latest comment
Hi there,
that's because the counter-value ist set dynamically by JavaScript. That's the reason why you don't get any value, file_get_contents only gets static content and doesn't trigger page events .
Regards
schnappi
that's because the counter-value ist set dynamically by JavaScript. That's the reason why you don't get any value, file_get_contents only gets static content and doesn't trigger page events .
Regards
schnappi
Hi @thankusomuch,
like @132658 wrote, this information is set by javascript and fetched via an ajax request from another page with a json result in which you can find the data. So it's very easy to extract the page visits with this code:
Best regards
Uwe
like @132658 wrote, this information is set by javascript and fetched via an ajax request from another page with a json result in which you can find the data. So it's very easy to extract the page visits with this code:
<?php
$artikelnr = "615080998";
$contents = file_get_contents("https://www.ebay-kleinanzeigen.de/s-vac-inc-get.json?adId=".$artikelnr);
$json = json_decode($contents);
echo "Visits: " . $json->numVisits;
?>
Uwe
if ($json->numVisits == 0){
echo "first visitor";
}else{
echo "you are not the first";
}