Get information from a JS-generated page with PHP

Asked

Viewed 118 times

-1

I have this page that’s on a server where I don’t have access. https://genuncoin.com/crypto/ Open it in the browser and you will see that its jquery generates a number.

I’m trying to get the number it generates but when I use this function:

$page = file_get_contents('http://genuncoin.com/crypto/');

the $page me returns her html without the number only the javas scripts and html of the screen. someone would know how to get the value that is generated by javascript??

1 answer

0

the characters being generated are in the variable balancebig and it is displayed on the screen as follows:

$('#bnkPrice').text(balancebig);

As you want to retrieve the information from this variable, I suggest you make an ajax request by sending the contents of this variable to your PHP script. An example of how you could do this is the following:

$.ajax({
    url: 'script.php',
    method: 'post',
    data: {variavel: balancebig},

    success: function(data, textStatus, jqXHR) {
        alert('Caracteres enviados');
    }
});

in your file (which for example I am using script.php you can recover the value using the superglobal post, as you would normally:

$dado = $_POST['variavel'];
  • then it will even but I need to pick up with php and not with ajax. because this way I can put a cron and save the information in the bank

  • But you’re sending it to a PHP script. Coming to this script do what you want with this value, including putting it in the database.

  • but everything has to be by backend no when someone access the page.

  • This is not making sense to me. If you have access to this page this is the best way to do it. If you can’t change the front script you want to mine data on the web. It gets a little more complicated

  • Edit your question by adding exactly what you want and how you want to get to the solution

  • this url is on another server and I want to pick up with my php only what returns but c vc access it the content of the div has nothing and I can not take with php and write only the number in db when I pull the get_gile there it brings everything but the result

  • This pq Javascript runs on the user’s machine file_get_contents reads the contents of a file and transforms it into a string. So there is no information you want in the file.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.