Re: Obtain javascript result

2016-12-29 Thread abaco121
Hi,
there's a problem in betexplorer?
this php page dont response anything to get odds

http://www.betexplorer.com/soccer/russia/youth-\league/matchdetails.php?matchid=rLu2Xsdi

from 24 december dont work

thanxs



Il giorno domenica 23 ottobre 2016 20:09:30 UTC+2, epr...@gmail.com ha scritto:
> Ok, I solved to this way:
> 
> from bs4 import BeautifulSoup
> from selenium import webdriver
> 
> driver = webdriver.Chrome()
> driver.get('http://www.betexplorer.com/soccer/russia/youth-\league/matchdetails.php?matchid=rLu2Xsdi')
> 
> pg_src = driver.page_source
> driver.close()
> soup = BeautifulSoup(pg_src, 'html.parser')
> # start from here I do something with soup ...
> 
> Windows 10 / Python 3.5.2
> 
> Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Obtain javascript result

2016-10-23 Thread eproser
Ok, I solved to this way:

from bs4 import BeautifulSoup
from selenium import webdriver

driver = webdriver.Chrome()
driver.get('http://www.betexplorer.com/soccer/russia/youth-\league/matchdetails.php?matchid=rLu2Xsdi')

pg_src = driver.page_source
driver.close()
soup = BeautifulSoup(pg_src, 'html.parser')
# start from here I do something with soup ...

Windows 10 / Python 3.5.2

Thanks


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Obtain javascript result

2016-10-22 Thread Bob Gailer
On Oct 22, 2016 12:45 AM,  wrote:
>
> Many Thanks to everybody.

You're welcome. It's fun to help in a challenging problem. Please let us
know what solution(s), if any, you have adopted, what problems, if any,
you've encountered, what Python version and operating system.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Obtain javascript result

2016-10-21 Thread eproser
Many Thanks to everybody.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Obtain javascript result

2016-10-21 Thread justin walters
On Fri, Oct 21, 2016 at 8:07 AM,  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.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Obtain javascript result

2016-10-21 Thread bob gailer

On 10/21/2016 11:07 AM, epro...@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.

What version of Python are you using, and what operating system?

I would use splinter (https://pypi.python.org/pypi/splinter)
From a command prompt: pip install splinter

The Python program (this is not tested; your mileage may vary):

from splinter import Browser
browser = Browser(browser)
page = 
browser.visit('http://www.betexplorer.com/soccer/russia/youth-league/matchdetails.php?matchid=rLu2Xsdi')

div = browser.find_by_id('be')
text = div.text

text looks like
"




Soccer » Russia » Youth League 2016/201720.10.2016


Cruzeiro-Corinthians
4:2
(1:1, 3:1)



14.Abila Ramon
(penalty kick) 59.Abila Ramon
63.Rodrigo Bruno
83.De Arrascaeta Giorgian




35.Rodriguinho
86.Rildo





1X2 Odds (25)
O/U (100)
AH (33)
DNB (11)
DC (20)
BTS (14)




Bookmakers: 251X2

 10Bet1.573.555.05
 12BET1.753.554.40
 188BET1.723.654.40
 888sport1.683.704.80
 bet-at-home1.673.404.42
 bet3651.733.604.75
 Betclic1.653.404.60
 Betfair1.663.404.40
 Betsafe1.683.504.25
 Betsson1.683.504.25
 BetVictor1.703.605.00
 Betway1.703.404.75
 bwin1.673.704.40
 ComeOn1.573.555.05
 Expekt1.653.404.60
 Interwetten1.703.454.50
 Ladbrokes1.733.605.00
 mybet1.753.504.00
 Pinnacle1.753.815.25
 SBOBET1.723.504.70
 Sportingbet1.673.604.60
 Tipico1.653.504.70
 Unibet1.683.704.80
 William Hill1.733.404.40
 youwin1.673.604.60


Average odds 1.693.544.63





close window

$(document).ready(function() {
matchdetails_init('rLu2Xsdi', '1x2');
});




"
I hope you know enough to extract the data you want. There are probably 
better ways to drill down to the relevant table rows, but I can't do 
that right now as I am having my own problem with splinter.


splinter is the only tool I know that will do this. There may be others.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Obtain javascript result

2016-10-21 Thread Michael Torrie
On 10/21/2016 07:29 AM, epro...@gmail.com wrote:
> Hello NG.
> 
> I'm new in Python for fun.
> 
> I have a html page (I load it by BeautifulSoap) that contain
> also this javascript code:
> ...
> 
>   $(document).ready(function() {
> matchdetails_init('rLu2Xsdi', '1x2');
>   });
> 
> ...
> Please, can You me to aim on the right way
> to obtain into a Python data structure 
> everything that JS code give back to browser.

All BeautifulSoup does is parse html. It doesn't run javascript.  To
obtain the html after the javascript has run, or to interact with the
Javascript you'll need a tool like Selenium[1], which has drivers for
Python and also Chrome or Firefox.  In other words you need a real
browser running that can execute the javascript.  After that you can
extract the html results using BeautifulSoup.

Google for many tutorials on using Selenium with python.

[1] https://pypi.python.org/pypi/selenium
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Obtain javascript result

2016-10-21 Thread eproser
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.





-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Obtain javascript result

2016-10-21 Thread Bob Gailer
On Oct 21, 2016 9:30 AM,  wrote:
>
> Hello NG.
>
> I'm new in Python for fun.
>
> I have a html page (I load it by BeautifulSoap) that contain
> also this javascript code:
> ...
> 
>   $(document).ready(function() {
> matchdetails_init('rLu2Xsdi', '1x2');
>   });
> 
> ...
> Please, can You me to aim on the right way
> to obtain into a Python data structure
> everything that JS code give back to browser.

Not without seeing the code for matchdetails_init. Likely we'd also need to
see the page source.

What do you expect to get?
-- 
https://mail.python.org/mailman/listinfo/python-list