NBA

This is my personal hobby project to learn web scraping in python. It’s a command line tool to access NBA scores, box-score and standings. Data is scraped from yahoo.

It uses lxml for web scraping. I found another more interesting package called scrapy for web scraping. Underneath scrapy also depends on lxml. So I decided to try out using lxml first.

screenshot

How to run?

It uses python3, and relies on few libraries. Recommended way to try it is by installing python3 via virtualenv

Install pip

pip is available if you install python using brew in mac. If it doesn’t work, you can try followings:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py

Using virtualenv

pip install virtualenv
virtualenv <DIR>
source <DIR>/bin/activate
deactivate

Dependencies

To install all dependencies at one go,

	pip install -r requirements.txt

Running NBA

python nba.py
python nba.py -y X
python nba.py -b MATCHID
python nba.py -s
python nba.py -p 'Kobe Bryant'
python nba.py -h

Usage: nba.py [options]

Options:
  -h, --help            show this help message and exit
  -s, --standings       Show NBA standings
  -b BOXID, --boxscore=BOXID
                        Show box score of a match ID
  -y MINUSDAY, --yesterday=MINUSDAY
                        Shows game scores of y days before today
  -p PLAYER_NAME, --player=PLAYER_NAME
                        Get Player profile

About

If you found this little tool useful, I’d love to hear about it. You can also follow me on Twitter at @iosCook