diff --git a/app/data_request.py b/app/data_request.py index 9a44167..74e1a58 100644 --- a/app/data_request.py +++ b/app/data_request.py @@ -37,7 +37,16 @@ def request_flickr(keywords) -> str: return html -def scrap_flickr(keywords) -> List[str]: +def extract_urls(images): + """ + Creates proper URLs from the regex matches + """ + links = findall("(live.staticflickr.com/\S+.jpg)", str(images)) + formatted_urls = ["https://" + link for link in links] + return formatted_urls + + +def scrape_flickr(keywords) -> List[str]: """ Creates a list of image links from a Flickr search """ @@ -46,5 +55,5 @@ def scrap_flickr(keywords) -> List[str]: images = soup.find_all( "div", class_="view photo-list-photo-view requiredToShowOnServer awake", ) - image_links = findall("(live.staticflickr.com/\S+.jpg)", str(images)) - return image_links + links = extract_urls(images) + return links diff --git a/app/routes.py b/app/routes.py index 7b62ab9..67cdcac 100644 --- a/app/routes.py +++ b/app/routes.py @@ -3,6 +3,7 @@ from flask import render_template from app import app from app.forms import DatasetForm from app.processing import process_data +from app.data_request import scrape_flickr @app.route("/") @@ -28,3 +29,9 @@ def visualization(): @app.route("/map") def map(): return render_template("map.html", title="Map") + + +@app.route("/photos") +def photos(): + images = scrape_flickr("paris") + return render_template("photos.html", title="Photos", images=images) diff --git a/app/templates/base.html b/app/templates/base.html index 5a3a6c3..50ee0fa 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -22,6 +22,7 @@ Home (current)