Proof of concept for parsing deliveroo sites for specific options to get some munch.
These are system recommendations, the programme may work on other configurations.
Python 3.9.0
BeautifulSoup 4.9.3
All packages not mentioned here should be included in Python 3.
Install the BeautifulSoup package (Python 3) for parsing the html.
pip3 install beautifulsoup4
Install the requests package (Python 3) for http requests.
pip3 install requests
The proof of concept is fairly basic, as of January 17, 2021 the use is as follows:
Command: python parser.py
N.B. if your python command is not mapped to Python 3 you may
need to instead use the command python3
.
Location
Command: python parser.py $LOCATION
Replace $LOCATION
with the location you want to search for.
N.B. The $LOCATION
must be in the
form of the url, so examples would be:
- for all London restaurant locations you would use
london
- for more specific options could do
london/bexleyheath
oraberdeen/hazelhead
_N.B.2_ If you are doing a non-london location you may also need to change the res_pattern on line 50 (as of March 11)
CSV Name
Comand: python parser.py $LOCATION $CSV_NAME
Replace $LOCATION
with the location you want to search for.
Replace $CSV_NAME
with the name of the file you want to save to.
N.B. The $CSV_NAME
should be a simple string, the code will add ".csv" to
the end of it, e.g.
bexley_restaurants
csvexample
As of January 17, 2020 you must have a $LOCATION
argument to have a
$CSV_NAME
argument.
The code is currently limited to only parse a few pages for efficient testing,
to test more values, change or remove the indices for href_links
in the for
loop of the restaurant_checker
function in parser.py
where specified
(~line 46).
The code writes the results to a csv file with Name, Sale, URL, and Location fields where Sale is a boolean displaying whether or not a given restaurant is running a sale.
- Make it so location can be outside london without code change
- Add flagging for arguments so
$CSV_NAME
can be specified without$LOCATION
- Potentially make multiple locations write to different csv pages