pythonapidata-extractionserpapi

is there any way to extract place details in google maps API?


Currently I am using Serp Api to extract places, but there is some information left. Like Question and Answers, At this place.(https://i.sstatic.net/giaUG.png)

I have tried this code

from serpapi import GoogleSearch

params = {
  "device": "desktop",
  "engine": "google_maps",
  "q": "ENOC | 1086 | Opp Emirates Int School",
  "google_domain": "google.com",
  "ll": "@40.7455096,-74.0083012,14z",
  "data": "!4m5!3m4!1s0x3e5f6cbec8c4424d:0x951dd76fff166da1!8m2!3d25.06475!4d55.1546667",
  "type": "place",
  "hl": "en",
  "api_key": "secret_api_key"
}

search = GoogleSearch(params)
results = search.get_dict()

Solution

  • "At this place" section has been recently added, as well as "Questions and Answers". Here's how you can access it:

    from serpapi import GoogleSearch
    import json
    
    params = {
      "api_key": "your serpapi key",
      "device": "desktop",
      "engine": "google_maps",
      "type": "place",
      "hl": "en",
      "data": "!4m5!3m4!1s0x3e5f6cbec8c4424d:0x951dd76fff166da1!8m2!3d25.06475!4d55.1546667"
    }
    
    search = GoogleSearch(params)
    results = search.get_dict()
    
    print(results['place_results']['at_this_place']['type'])
    
    print(json.dumps(results['place_results']['at_this_place']['places'], indent=2))
    
    print(json.dumps(results['place_results']['questions_and_answers'], indent=2))
    

    Outputs:

    [{'title': 'Food & Drink', 'places': 1}]
    [
      {
        "position": 1,
        "title": "Jailbird - Meadows",
        "data_id": "0x3e5f6dc2b7d6a72b:0x99c79a98d0fa228c",
        "data_cid": "11080995389300155020",
        "reviews_link": "https://serpapi.com/search.json?data_id=0x3e5f6dc2b7d6a72b%3A0x99c79a98d0fa228c&engine=google_maps_reviews&hl=en",
        "photos_link": "https://serpapi.com/search.json?data_id=0x3e5f6dc2b7d6a72b%3A0x99c79a98d0fa228c&engine=google_maps_photos&hl=en",
        "gps_coordinates": {
          "latitude": 25.0651768,
          "longitude": 55.154764
        },
        "place_id_search": "https://serpapi.com/search.json?data=%214m5%213m4%211s0x3e5f6dc2b7d6a72b%3A0x99c79a98d0fa228c%218m2%213d25.0651768%214d55.154764&engine=google_maps&google_domain=google.com&hl=en&type=place",
        "rating": 188.0,
        "reviews": 4,
        "type": "Restaurant",
        "address": "Meadows Enoc station 1 Rd Meadows - opp. Emirates Int School - Dubai - United Arab Emirates",
        "open_state": "Open \u22c5 Closes 1AM",
        "hours": [
          {
            "wednesday": "11AM\u20131AM"
          },
          {
            "thursday": "11AM\u20131AM"
          },
          {
            "friday": "11AM\u20133AM"
          },
          {
            "saturday": "11AM\u20133AM"
          },
          {
            "sunday": "11AM\u20131AM"
          },
          {
            "monday": "11AM\u20131AM"
          },
          {
            "tuesday": "11AM\u20131AM"
          }
        ],
        "thumbanil": "https://lh5.googleusercontent.com/p/AF1QipME1-tektJ33lViD4v1-w4exH0ced2wyoYTk9Zq=w86-h86-n-k-no"
      }
    ]
    
    [
      {
        "question": {
          "user": {
            "name": "Selim Soliman",
            "link": "https://www.google.com/maps/contrib/114510311589225536034",
            "thumbnail": "https://lh4.ggpht.com/-Wq-1BTbSFgs/AAAAAAAAAAI/AAAAAAAAAAA/Nb2aqnfEOzI/c0x00000000-cc-rp-mo/photo.jpg"
          },
          "text": "When do you open",
          "date": "a month ago",
          "language": "en"
        },
        "answer": {
          "user": {
            "name": "Momen Abdalaziz",
            "link": "https://www.google.com/maps/contrib/114406017345938938689",
            "local_guide_level": 6,
            "thumbnail": "https://lh3.ggpht.com/-I_1mrBnJ0EY/AAAAAAAAAAI/AAAAAAAAAAA/fKw4c8rVE2U/c0x00000000-cc-rp-mo-ba4/photo.jpg"
          },
          "text": "It is open 24 hours already",
          "date": "a month ago",
          "language": "en"
        },
        "total_answers": 1
      }
    ]
    

    As a side note, you don't need to use ll when data parameter is used (place results).

    This is because data parameter holds the same information also, i.e latitude, and longitude except for zoom as in the ll parameter. In the case of place results, zoom is not needed :-)

    Hope it makes sense.