Obtain javascript result

justin walters walters.justin01 at gmail.com
Fri Oct 21 13:13:15 EDT 2016


On Fri, Oct 21, 2016 at 8:07 AM, <eproser at gmail.com> wrote:

> Yes,
>
> the page is http://www.betexplorer.com/next/soccer/
> and You have to open any match You want.
>
> This pop-up new windows with match detail and odds
> (if present).
>
> I try to extract home team, away team, results, and
> bet365's bookmaker odds.
>
> I can't continue in my fun analyses because the odds
> are returned through that javascript code and
> I don't know how manage it in python
> to take that results.
>


The data is being obtained through an ajax call:

jQuery.ajax({
        url: '/gres/ajax-matchdetails.php',
        type: 'GET',
        cache: false,
        dataType: 'json',
        success: function(data)
        {
            if (data.user_logged)
            {
                user.logged = true;
                user.oddsformat = data.oddsformat;
            }
            bookmaker_urls = data.bookmaker_urls;

            ajax_to_call--;
            if (ajax_to_call == 0)
            {
                matchdetails_finish();
                $('#odds-all-loader').remove();
                $('#odds-all').show();
            }
        }
    });

    jQuery.ajax({
        url: '/gres/ajax-matchodds.php',
        type: 'GET',
        data: 't=d&e=' + eventid + '&b=' + bettype,
        success: function(data)
        {
            $('#odds-all').html(data);

            ajax_to_call--;
            if (ajax_to_call == 0)
            {
                matchdetails_finish();
                $('#odds-all-loader').remove();
                $('#odds-all').show();
            }
        }

You can see this by opening up your developer tools (chrome or Firefox) and
navigating to the debugger/scripts tab where you will find the
"matchdetails_init" function.

However, I tried fetching the "ajax-matchdetails.php" endpoint via httpie,
and I received a 404 page. Investigating the request via the developer
console led to some strange results as well. There was a small piece of
json data returned containing the keys "user_logged" and "bookmaker_urls".
There was no data about the match at all.

There are several other ajax calls in the script, so you may want to check
those out.

However, it seems like the match data itself is actually populated with
data server-side via a PHP script.

You should be able to get the link for a match, point beautiful soup at it,
parse it, and get the data.



More information about the Python-list mailing list