andrewffff / nullprovide

a ZeroCater scraper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nullprovide -- a ZeroCater scraper
by timdoug, me@timdoug.com

Problem: ZeroCater doesn't have an API.
Solution: nullprovide!

How-to
------
ZeroCater now requires authentication. At the bottom-right of the menu page
after logging in is a URL under the "Share this page with your coworkers" title
with the format <http://www.zerocater.com/menu/xxxxxxx/>. The x's are the
account_key you need to pass to nullprovide. It hasn't changed for me in the
past few weeks, but who knows what the future holds. YMMV &c.

Requirements
------------
* Python (tested on 2.7)
* BeautifulSoup 4.x

What works
----------
* Extracting meal name, date, restaurant
* Multiple meals per day

Use it on the command line (hey look it's valid JSON!)
------------------------------------------------------
$ python nullprovide.py
usage: nullprovide.py account_key
$ python nullprovide.py xxxxxxx
[
    {
        "date": "2012-06-25 12:00:00", 
        "name": "Asian Box", 
        "restaurant": "Asian Box Palo Alto"
    }, 
    {
        "date": "2012-06-28 12:00:00", 
        "name": "Chicken Wings", 
        "restaurant": "BonChon Chicken"
    }, 
    {
        "date": "2012-07-02 12:00:00", 
        "name": "Vietnamese", 
        "restaurant": "Saba Cafe"
    }, 
    {
        "date": "2012-07-05 12:00:00", 
        "name": "Taco Bar", 
        "restaurant": "Baysider Cafe"
    }
]

Or in Python
------------
$ ipython
...
In [1]: from nullprovide import NullProvide

In [2]: NullProvide('xxxxxxx').meals
Out[2]: 
[{'date': datetime.datetime(2012, 6, 25, 12, 0),
  'name': u'Asian Box',
  'restaurant': u'Asian Box Palo Alto'},
 {'date': datetime.datetime(2012, 6, 28, 12, 0),
  'name': u'Chicken Wings',
  'restaurant': u'BonChon Chicken'},
 {'date': datetime.datetime(2012, 7, 2, 12, 0),
  'name': u'Vietnamese',
  'restaurant': u'Saba Cafe'},
 {'date': datetime.datetime(2012, 7, 5, 12, 0),
  'name': u'Taco Bar',
  'restaurant': u'Baysider Cafe'}]

About

a ZeroCater scraper


Languages

Language:Python 100.0%