Scrape for "paris coronavirus" images

This commit is contained in:
coolneng 2020-06-15 01:19:13 +02:00
parent da4d9b1dad
commit 8307a54fe0
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
4 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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)

View File

@ -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": [

View File

@ -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