diff --git a/main.py b/main.py index 4dde2a2..10de7c4 100644 --- a/main.py +++ b/main.py @@ -248,6 +248,24 @@ def route_sitemap(): return render_template("sitemap.html", data=groups) +@app.route('/sitemap/projects///') +def route_sitemap_projects(category, channel): + data = requests.get(f"https://www.instructables.com/sitemap/projects/{category}/{channel}/") + if data.status_code != 200: + return Response(render_template(str(data.status_code) + ".html"), status=data.status_code) + + soup = BeautifulSoup(data.text, "html.parser") + + main = soup.select("div.sitemap-content")[0] + + articles = [] + for li in main.select("ul.sitemap-listing li"): + article = li.a.text + article_link = li.a["href"] + articles.append([article, article_link]) + + return render_template("sitemap-projects.html", data=[category.title(), get_channel_name(channel), articles]) + @app.route('/contest/archive/') def route_contest_archive(): page = 1 diff --git a/templates/sitemap-projects.html b/templates/sitemap-projects.html new file mode 100644 index 0000000..a8e709d --- /dev/null +++ b/templates/sitemap-projects.html @@ -0,0 +1,22 @@ + + + + Sitemap - {{ data[1] }} {{ data[0] }} Projects - Destructables + + + {% include "style.html" %} + + + + {% include "header.html" %} +

Sitemap/{{ data[1] }} {{ data[0] }} Projects

+
+ +
+ {% include "footer.html" %} + +