csshen / atlas-obscura-api

A simple flask api for Atlas Obscura.
39 stars 12 forks source link

The /api/atlas/attractions/<country> endpoint is giving a status code of 200, but a result of null #4

Open CLLane opened 4 years ago

CLLane commented 4 years ago

Problem

I am trying to make a call through post man to /api/atlas/attractions/japan?city=tokyo&sort=recent&limit=3 and the status code I am receiving is a 200 OK, however the object I am being returned is:

{
    "status": "success",
    "results": null,
    "Attractions": null
}

The other endpoints are working fine and I am getting back data.

Not sure what is going on but I thought I would throw this up here and see if anyone had suggestions.

mileyvirus commented 4 years ago

The classes for the /things-to-do/ pages changed so it's only a matter of updating them.

Check pull request #5

So in scraper.py, replace everything from line 60 to line 83 with:

    for card in soup.find_all('a',
    class_='Card --content-card-v2 --content-card-item Card--flat')[:limit]:
        # CREATE NEW ATTRACTION
        curr_attraction = {}
        # LOCATION (City, Town)
        curr_attraction['location'] = card.find('div',
        class_='Card__hat --place').text
        # NAME
        curr_attraction['name'] = card.find('h3',
        class_='Card__heading --content-card-v2-title').find("span").text
        # Description
        curr_attraction['description'] = card.find('div',
        class_='Card__content js-subtitle-content').text
        # Coordinates
        curr_attraction['coordinates'] = [float(card["data-lat"]), float(card["data-lng"])]
        # Image Thumbnail
        curr_attraction['img'] = card.find('img')['data-src']
        # PATH
        curr_attraction['path'] = card['href']

        attractions.append(curr_attraction)

    return attractions