2012-10-15 111 views
0

我正在尋找一種方法來抓取這個網站的數據:http://www.dectech.org/football/index.php最好使用Python。我似乎遇到的困難是數據沒有被硬編碼到網站的HTML中,並且似乎被包裹在一種叫做mochi-kit(http://mochi.github.com/mochikit/)的東西中。scrape dechtech網站使用python

我已經做了一些研究,似乎BeautifulSoup可能對我有用,但我想我可能沒有正確使用它。我也嘗試使用urllib來解析網站沒有喜悅。

我的最終目標是制定一個監控dectech網站的計劃,並在發佈新預測時自動使用Betfair API挑選價值投注。

回答

2

它看起來像正在由JavaScript從這個網址

http://www.dectech.org/cgi-bin/new_site/GetUpcomingGames.pl?divID=0

返回

{ 
    "games" : [ 
     { 
     "apct" : 0.377838, 
     "dpct" : 0.263445, 
     "expGoalDiff" : -0.04086, 
     "awayID" : "6", 
     "homeID" : "17", 
     "date" : "20/10/2012", 
     "away" : "Chelsea", 
     "home" : "Tottenham", 
     "hpct" : 0.358717 
     }, 
     { 
     "apct" : 0.237829, 
     "dpct" : 0.250146, 
     "expGoalDiff" : 0.594234, 
     "awayID" : "1", 
     "homeID" : "8", 
     "date" : "20/10/2012", 
     "away" : "Aston Villa", 
     "home" : "Fulham", 
     "hpct" : 0.512025 
     }, /* shortened for brevity */ 

那麼你是非常幸運加載的數據,你不需要抓取數據(這很棘手),你只需要檢索它並解析它,就像他們正在用年糕一樣。

Python的simplejson模塊將能夠分析它...

+0

謝謝,這是真正的幫助!這正是我所期待的。順便說一句,如果任何人有興趣只使用http://www.dectech.org/cgi-bin/new_site/GetUpcomingGames.pl給你所有即將到來的比賽。 – James