From 8307a54fe046815f5cae8a5f9bc18558484c6180 Mon Sep 17 00:00:00 2001 From: coolneng Date: Mon, 15 Jun 2020 01:19:13 +0200 Subject: [PATCH] Scrape for "paris coronavirus" images --- app/data_request.py | 4 ++-- app/routes.py | 2 +- constants.py | 2 +- tests/preprocessing_test.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/data_request.py b/app/data_request.py index 74e1a58..fd553ac 100644 --- a/app/data_request.py +++ b/app/data_request.py @@ -4,14 +4,14 @@ from typing import List from bs4 import BeautifulSoup from requests import get -from constants import FLICKR_URL, URL +from constants import FLICKR_URL, DATASET_URL def format_url(dataset) -> str: """ Constructs the API's URL for the requested dataset """ - link = URL.format(dataset) + link = DATASET_URL.format(dataset) return link diff --git a/app/routes.py b/app/routes.py index 67cdcac..2e99bca 100644 --- a/app/routes.py +++ b/app/routes.py @@ -33,5 +33,5 @@ def map(): @app.route("/photos") def photos(): - images = scrape_flickr("paris") + images = scrape_flickr("paris coronavirus") return render_template("photos.html", title="Photos", images=images) diff --git a/constants.py b/constants.py index 31ee60a..aaa1b3f 100644 --- a/constants.py +++ b/constants.py @@ -4,7 +4,7 @@ DATASETS = [ "deconfinement-parking-relais-doublement-des-places", "deconfinement-rues-amenagees-pour-pietons", ] -URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset={}&q=&rows=-1" +DATASET_URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset={}&q=&rows=-1" FLICKR_URL = "https://www.flickr.com/search/?text={}" COLUMNS = { "deconfinement-pistes-cyclables-temporaires": [ diff --git a/tests/preprocessing_test.py b/tests/preprocessing_test.py index 08f74d0..74d7886 100644 --- a/tests/preprocessing_test.py +++ b/tests/preprocessing_test.py @@ -3,7 +3,7 @@ from requests import get from app.preprocessing import create_dataframe from app.data_request import request_dataset -from constants import COLUMNS, DATASETS, URL +from constants import COLUMNS, DATASETS, DATASET_URL def test_dataset_request(): @@ -11,7 +11,7 @@ def test_dataset_request(): Checks that the datasets URLs are reachable """ for dataset in DATASETS: - response = get(URL.format(dataset)) + response = get(DATASET_URL.format(dataset)) assert response.status_code == 200