I just started creating some Python script because some site scrapers don't work that well. But still have to find out howto create a plugin / add-on for XBMC. Here is the scraper Python script I have so far. Using Beautiful Soup 3.2:
Code:
# Import the classes that are needed
import urllib2
from BeautifulSoup import BeautifulSoup
# URL to scrape and open it with the urllib2
url = 'http://www.wiziwig.tv/competition.php?competitionid=92&part=sports&discipline=football'
source = urllib2.urlopen(url)
# Turn the saved source into a BeautifulSoup object
soup = BeautifulSoup(source)
# Find all <tr> elements that contain the matches, skip the rows with the home team text 'Dutch KNVB Beker'
# Join the times together...
for tr in soup.findAll('tr', {'class': ['odd', 'even']}):
home_team = tr.find('td', {'class': 'home'}).text
if home_team == 'Dutch KNVB Beker':
continue
date = tr.find('div', {'class': 'date'}).text
time = ' - '.join([span.text for span in tr.findAll('span', {'class': 'time'})])
away_team = tr.find('td', {'class': 'away'}).text
broadcast = tr.find('a', {'class': 'broadcast'})['href']
print date, time, home_team, away_team, broadcast
And finally the next for scraping the streams:
Code:
# Import the classes that are needed
import urllib2
from BeautifulSoup import BeautifulSoup
# URL to scrape and open it with the urllib2
url = 'http://www.wiziwig.tv/broadcast.php?matchid=219751&part=sports'
source = urllib2.urlopen(url)
# Turn the saved source into a BeautifulSoup object
soup = BeautifulSoup(source)
stationName = ''
for tr in soup.findAll('tr', {'class': ['broadcast', 'streamrow even', 'streamrow odd']}):
if tr['class'] == 'broadcast':
stationName = tr.findAll('td')[1].text
else:
kindStream = tr.findAll('td')[0].text
streamBitrate = tr.findAll('td')[2].text
streamStrength = tr.find('div', {'class': 'rating'})['rel']
streamUrl = tr.find('a', {'class': 'broadcast go'})['href']
print stationName, kindStream, streamBitrate, streamStrength, streamUrl
Everything is now still static, but will work on the XBMC plugin. Maybe someone can test with this code or if he his some other code.