-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathriverford.py
27 lines (20 loc) · 925 Bytes
/
riverford.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# A script to find the options in the upcoming Riverford veg boxes.
import requests
from brackets import pairs, nested_pairs
if __name__=="__main__":
boxes = {"small-veg":"http://www.riverford.co.uk/exe/shop/veg-fruit-meat-boxes/veg-fruit-boxes/box-1-small-vegbox-original"}
for name, box in boxes.items():
r = requests.get(box)
page = str(r.content, encoding = "utf-8")
container_name = 'div class="product-long-description"'
for i, j in pairs(page):
print(page[i:i+len(container_name)], len(container_name))
if page[i:i+len(container_name)] == container_name:
container = page[i:j]
print(container)
items = []
for i, j in nested_pairs(container):
if page[i:i+2] == "li":
links.append(page[i:j])
for link in links:
print(link[8:-1])