Merge branch 'basset' into coolneng

This commit is contained in:
coolneng 2020-06-14 21:25:09 +02:00
commit b74ceb05c8
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
2 changed files with 26 additions and 0 deletions

25
app/pruebascraping.py Normal file
View File

@ -0,0 +1,25 @@
from bs4 import BeautifulSoup
from requests import get
from constants import FLICKR_URL
from re import findall
from typing import List
def request_flickr(keywords) -> str:
search_url = FLICKR_URL.format(keywords)
result = get(search_url)
html = result.text
return html
def scrap_flickr(keywords) -> List[str]:
html = request_flickr(keywords)
soup = BeautifulSoup(html, features="html.parser")
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
scrap_flickr("paris")

View File

@ -5,6 +5,7 @@ DATASETS = [
"deconfinement-rues-amenagees-pour-pietons", "deconfinement-rues-amenagees-pour-pietons",
] ]
URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset={}&q=&rows=-1" URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset={}&q=&rows=-1"
FLICKR_URL = "https://www.flickr.com/search/?text={}"
COLUMNS = { COLUMNS = {
"deconfinement-pistes-cyclables-temporaires": [ "deconfinement-pistes-cyclables-temporaires": [
"fields.geo_shape.coordinates", "fields.geo_shape.coordinates",