Gosse Minnema
commited on
Commit
·
2454a5f
1
Parent(s):
54a6ac2
Add recipe URLs to parsed JSON
Browse files
scrape.py
CHANGED
@@ -52,6 +52,8 @@ def parse_recipe(filename):
|
|
52 |
|
53 |
recipe_title = soup.select("#firstHeading")[0].get_text().replace("Cookbook:", "")
|
54 |
|
|
|
|
|
55 |
infoboxes = soup.select("table.infobox")
|
56 |
if len(infoboxes) >= 1:
|
57 |
recipe_info = parse_infobox(infoboxes[0])
|
@@ -84,7 +86,8 @@ def parse_recipe(filename):
|
|
84 |
"section": section_name
|
85 |
})
|
86 |
return {
|
87 |
-
"
|
|
|
88 |
"infobox": recipe_info,
|
89 |
"text_lines": text_lines
|
90 |
}
|
|
|
52 |
|
53 |
recipe_title = soup.select("#firstHeading")[0].get_text().replace("Cookbook:", "")
|
54 |
|
55 |
+
recipe_url = soup.find("link", attrs={"rel": "canonical"})["href"]
|
56 |
+
|
57 |
infoboxes = soup.select("table.infobox")
|
58 |
if len(infoboxes) >= 1:
|
59 |
recipe_info = parse_infobox(infoboxes[0])
|
|
|
86 |
"section": section_name
|
87 |
})
|
88 |
return {
|
89 |
+
"url": recipe_url,
|
90 |
+
"title": recipe_title,
|
91 |
"infobox": recipe_info,
|
92 |
"text_lines": text_lines
|
93 |
}
|