|
| 1 | +# Outscraper SDK in Python |
| 2 | +Python SDK that allows using [Outscraper's services](https://outscraper.com/services/) and [Outscraper's API](https://app.outscraper.com/api-docs). |
| 3 | + |
| 4 | +## List of Supported Services |
| 5 | +- [Google Maps Scraper](https://outscraper.com/google-maps-scraper/) |
| 6 | +- [Google Maps Reviews Scraper](https://outscraper.com/google-maps-reviews-scraper/) |
| 7 | +- [Google Maps Photos Scraper](https://outscraper.com/google-maps-photos-scraper/) |
| 8 | +- [Google Maps Directions Scraper](https://outscraper.com/google-maps-traffic-extractor/) |
| 9 | +- [Google Play Reviews Scraper](https://outscraper.com/google-maps-photos-scraper/) |
| 10 | +- [Emails & Contacts Scraper](https://outscraper.com/emails-scraper/) |
| 11 | + |
| 12 | +[API Docs](https://app.outscraper.com/api-docs) |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +Python 3+ |
| 17 | +```bash |
| 18 | +pip install google-services-api |
| 19 | +``` |
| 20 | + |
| 21 | +[Link to the python package page](https://pypi.org/project/google-services-api/) |
| 22 | + |
| 23 | +## Initialization |
| 24 | +```python |
| 25 | +from outscraper import ApiClient |
| 26 | + |
| 27 | +api_client = ApiClient(api_key='SECRET_API_KEY') |
| 28 | +``` |
| 29 | +[Link to the profile page to create the API key](https://app.outscraper.com/profile) |
| 30 | + |
| 31 | +## Scrape Google Search |
| 32 | + |
| 33 | +```python |
| 34 | +# Googel Search |
| 35 | +result = api_client.google_search('bitcoin') |
| 36 | + |
| 37 | +# Googel Search News |
| 38 | +result = api_client.google_search_news('election', language='en') |
| 39 | +``` |
| 40 | + |
| 41 | +## Scrape Google Maps (Places) |
| 42 | + |
| 43 | +```python |
| 44 | +# Search for businesses in specific locations: |
| 45 | +result = api_client.google_maps_search('restaurants brooklyn usa', limit=20, language='en') |
| 46 | + |
| 47 | +# Get data of the specific place by id |
| 48 | +result = api_client.google_maps_search('ChIJrc9T9fpYwokRdvjYRHT8nI4', language='en') |
| 49 | + |
| 50 | +# Search with many queries (batching) |
| 51 | +result = api_client.google_maps_search([ |
| 52 | + 'restaurants brooklyn usa', |
| 53 | + 'bars brooklyn usa', |
| 54 | +], language='en') |
| 55 | + |
| 56 | +``` |
| 57 | + |
| 58 | +## Scrape Google Maps Reviews |
| 59 | + |
| 60 | +```python |
| 61 | +# Get reviews of the specific place by id |
| 62 | +result = api_client.google_maps_reviews('ChIJrc9T9fpYwokRdvjYRHT8nI4', reviewsLimit=20, language='en') |
| 63 | + |
| 64 | +# Get reviews for places found by search query |
| 65 | +result = api_client.google_maps_reviews('Memphis Seoul brooklyn usa', reviewsLimit=20, limit=500, language='en') |
| 66 | + |
| 67 | +# Get only new reviews during last 24 hours |
| 68 | +from datetime import datetime, timedelta |
| 69 | +yesterday_timestamp = int((datetime.now() - timedelta(1)).timestamp()) |
| 70 | + |
| 71 | +result = api_client.google_maps_reviews( |
| 72 | + 'ChIJrc9T9fpYwokRdvjYRHT8nI4', sort='newest', cutoff=yesterday_timestamp, reviewsLimit=100, language='en') |
| 73 | +``` |
| 74 | + |
| 75 | +## Scrape Google Maps Photos |
| 76 | + |
| 77 | +```python |
| 78 | +result = api_client.google_maps_photos( |
| 79 | + 'Trump Tower, NY, USA', photosLimit=20, language='en') |
| 80 | +``` |
| 81 | + |
| 82 | +## Scrape Google Maps Directions |
| 83 | + |
| 84 | +```python |
| 85 | +result = api_client.google_maps_directions(['29.696596, 76.994928 30.7159662444353, 76.8053887016268', '29.696596, 76.994928 30.723065, 76.770169']) |
| 86 | +``` |
| 87 | + |
| 88 | +## Scrape Google Play Reviews |
| 89 | + |
| 90 | +```python |
| 91 | +result = api_client.google_play_reviews( |
| 92 | + 'com.facebook.katana', reviewsLimit=20, language='en') |
| 93 | +``` |
| 94 | + |
| 95 | +## Emails And Contacts Scraper |
| 96 | + |
| 97 | +```python |
| 98 | +result = api_client.emails_and_contacts(['outscraper.com']) |
| 99 | +``` |
| 100 | + |
| 101 | +## Responses examples |
| 102 | + |
| 103 | +Google Maps (Places) response example: |
| 104 | +```json |
| 105 | +[ |
| 106 | + [ |
| 107 | + { |
| 108 | + "name": "Colonie", |
| 109 | + "full_address": "127 Atlantic Ave, Brooklyn, NY 11201", |
| 110 | + "borough": "Brooklyn Heights", |
| 111 | + "street": "127 Atlantic Ave", |
| 112 | + "city": "Brooklyn", |
| 113 | + "postal_code": "11201", |
| 114 | + "country_code": "US", |
| 115 | + "country": "United States of America", |
| 116 | + "us_state": "New York", |
| 117 | + "state": "New York", |
| 118 | + "plus_code": null, |
| 119 | + "latitude": 40.6908464, |
| 120 | + "longitude": -73.9958422, |
| 121 | + "time_zone": "America/New_York", |
| 122 | + "popular_times": null, |
| 123 | + "site": "http://www.colonienyc.com/", |
| 124 | + "phone": "+1 718-855-7500", |
| 125 | + "type": "American restaurant", |
| 126 | + "category": "restaurants", |
| 127 | + "subtypes": "American restaurant, Cocktail bar, Italian restaurant, Organic restaurant, Restaurant, Wine bar", |
| 128 | + "posts": null, |
| 129 | + "rating": 4.6, |
| 130 | + "reviews": 666, |
| 131 | + "reviews_data": null, |
| 132 | + "photos_count": 486, |
| 133 | + "google_id": "0x89c25a4590b8c863:0xc4a4271f166de1e2", |
| 134 | + "place_id": "ChIJY8i4kEVawokR4uFtFh8npMQ", |
| 135 | + "reviews_link": "https://search.google.com/local/reviews?placeid=ChIJY8i4kEVawokR4uFtFh8npMQ&q=restaurants+brooklyn+usa&authuser=0&hl=en&gl=US", |
| 136 | + "reviews_id": "-4277250731621359134", |
| 137 | + "photo": "https://lh5.googleusercontent.com/p/AF1QipN_Ani32z-7b9XD182oeXKgQ-DIhLcgL09gyMZf=w800-h500-k-no", |
| 138 | + "street_view": "https://lh5.googleusercontent.com/p/AF1QipN_Ani32z-7b9XD182oeXKgQ-DIhLcgL09gyMZf=w1600-h1000-k-no", |
| 139 | + "working_hours_old_format": "Monday: 5\\u20139:30PM | Tuesday: Closed | Wednesday: Closed | Thursday: 5\\u20139:30PM | Friday: 5\\u20139:30PM | Saturday: 11AM\\u20133PM,5\\u20139:30PM | Sunday: 11AM\\u20133PM,5\\u20139:30PM", |
| 140 | + "working_hours": { |
| 141 | + "Monday": "5\\u20139:30PM", |
| 142 | + "Tuesday": "Closed", |
| 143 | + "Wednesday": "Closed", |
| 144 | + "Thursday": "5\\u20139:30PM", |
| 145 | + "Friday": "5\\u20139:30PM", |
| 146 | + "Saturday": "11AM\\u20133PM,5\\u20139:30PM", |
| 147 | + "Sunday": "11AM\\u20133PM,5\\u20139:30PM" |
| 148 | + }, |
| 149 | + "business_status": "OPERATIONAL", |
| 150 | + "about": { |
| 151 | + "Service options": { |
| 152 | + "Dine-in": true, |
| 153 | + "Delivery": false, |
| 154 | + "Takeout": false |
| 155 | + }, |
| 156 | + "Health & safety": { |
| 157 | + "Mask required": true, |
| 158 | + "Staff required to disinfect surfaces between visits": true |
| 159 | + }, |
| 160 | + "Highlights": { |
| 161 | + "Fast service": true, |
| 162 | + "Great cocktails": true, |
| 163 | + "Great coffee": true |
| 164 | + }, |
| 165 | + "Popular for": { |
| 166 | + "Lunch": true, |
| 167 | + "Dinner": true, |
| 168 | + "Solo dining": true |
| 169 | + }, |
| 170 | + "Accessibility": { |
| 171 | + "Wheelchair accessible entrance": true, |
| 172 | + "Wheelchair accessible restroom": true, |
| 173 | + "Wheelchair accessible seating": true |
| 174 | + }, |
| 175 | + "Offerings": { |
| 176 | + "Coffee": true, |
| 177 | + "Comfort food": true, |
| 178 | + "Healthy options": true, |
| 179 | + "Organic dishes": true, |
| 180 | + "Small plates": true, |
| 181 | + "Vegetarian options": true, |
| 182 | + "Wine": true |
| 183 | + }, |
| 184 | + "Dining options": { |
| 185 | + "Dessert": true |
| 186 | + }, |
| 187 | + "Amenities": { |
| 188 | + "High chairs": true |
| 189 | + }, |
| 190 | + "Atmosphere": { |
| 191 | + "Casual": true, |
| 192 | + "Cozy": true, |
| 193 | + "Romantic": true, |
| 194 | + "Upscale": true |
| 195 | + }, |
| 196 | + "Crowd": { |
| 197 | + "Groups": true |
| 198 | + }, |
| 199 | + "Planning": { |
| 200 | + "Dinner reservations recommended": true, |
| 201 | + "Accepts reservations": true, |
| 202 | + "Usually a wait": true |
| 203 | + }, |
| 204 | + "Payments": { |
| 205 | + "Credit cards": true |
| 206 | + } |
| 207 | + }, |
| 208 | + "range": "$$$", |
| 209 | + "reviews_per_score": { |
| 210 | + "1": 9, |
| 211 | + "2": 10, |
| 212 | + "3": 47, |
| 213 | + "4": 129, |
| 214 | + "5": 471 |
| 215 | + }, |
| 216 | + "reserving_table_link": "https://resy.com/cities/ny/colonie", |
| 217 | + "booking_appointment_link": "https://resy.com/cities/ny/colonie", |
| 218 | + "owner_id": "114275131377272904229", |
| 219 | + "verified": true, |
| 220 | + "owner_title": "Colonie", |
| 221 | + "owner_link": "https://www.google.com/maps/contrib/114275131377272904229", |
| 222 | + "location_link": "https://www.google.com/maps/place/Colonie/@40.6908464,-73.9958422,14z/data=!4m8!1m2!2m1!1sColonie!3m4!1s0x89c25a4590b8c863:0xc4a4271f166de1e2!8m2!3d40.6908464!4d-73.9958422" |
| 223 | + }, |
| 224 | + ... |
| 225 | + ] |
| 226 | +] |
| 227 | +``` |
| 228 | + |
| 229 | + |
| 230 | +Google Maps Reviews response example: |
| 231 | +```json |
| 232 | +{ |
| 233 | + "name": "Memphis Seoul", |
| 234 | + "address": "569 Lincoln Pl, Brooklyn, NY 11238, \\u0421\\u043f\\u043e\\u043b\\u0443\\u0447\\u0435\\u043d\\u0456 \\u0428\\u0442\\u0430\\u0442\\u0438", |
| 235 | + "address_street": "569 Lincoln Pl", |
| 236 | + "address_borough": "\\u041a\\u0440\\u0430\\u0443\\u043d-\\u0413\\u0430\\u0439\\u0442\\u0441", |
| 237 | + "address_city": "Brooklyn", |
| 238 | + "time_zone": "America/New_York", |
| 239 | + "type": "\\u0420\\u0435\\u0441\\u0442\\u043e\\u0440\\u0430\\u043d", |
| 240 | + "types": "\\u0420\\u0435\\u0441\\u0442\\u043e\\u0440\\u0430\\u043d", |
| 241 | + "postal_code": "11238", |
| 242 | + "latitude": 40.6717258, |
| 243 | + "longitude": -73.9579098, |
| 244 | + "phone": "+1 347-349-2561", |
| 245 | + "rating": 3.9, |
| 246 | + "reviews": 32, |
| 247 | + "site": "http://www.getmemphisseoul.com/", |
| 248 | + "photos_count": 77, |
| 249 | + "google_id": "0x89c25bb5950fc305:0x330a88bf1482581d", |
| 250 | + "reviews_link": "https://www.google.com/search?q=Memphis+Seoul,+569+Lincoln+Pl,+Brooklyn,+NY+11238,+%D0%A1%D0%BF%D0%BE%D0%BB%D1%83%D1%87%D0%B5%D0%BD%D1%96+%D0%A8%D1%82%D0%B0%D1%82%D0%B8&ludocid=3677902399965648925#lrd=0x89c25bb5950fc305:0x330a88bf1482581d,1", |
| 251 | + "reviews_id": "3677902399965648925", |
| 252 | + "photo": "https://lh5.googleusercontent.com/p/X_6-QqMphC_ctqs3bHSqFg", |
| 253 | + "working_hours": "\\u0432\\u0456\\u0432\\u0442\\u043e\\u0440\\u043e\\u043a: 16:00\\u201322:00 | \\u0441\\u0435\\u0440\\u0435\\u0434\\u0430: 16:00\\u201322:00 | \\u0447\\u0435\\u0442\\u0432\\u0435\\u0440: 16:00\\u201322:00 | \\u043f\\u02bc\\u044f\\u0442\\u043d\\u0438\\u0446\\u044f: 16:00\\u201322:00 | \\u0441\\u0443\\u0431\\u043e\\u0442\\u0430: 16:00\\u201322:00 | \\u043d\\u0435\\u0434\\u0456\\u043b\\u044f: 16:00\\u201322:00 | \\u043f\\u043e\\u043d\\u0435\\u0434\\u0456\\u043b\\u043e\\u043a: 16:00\\u201322:00", |
| 254 | + "reviews_per_score": "1: 6, 2: 0, 3: 4, 4: 3, 5: 19", |
| 255 | + "verified": true, |
| 256 | + "reserving_table_link": null, |
| 257 | + "booking_appointment_link": null, |
| 258 | + "owner_id": "100347822687163365487", |
| 259 | + "owner_link": "https://www.google.com/maps/contrib/100347822687163365487", |
| 260 | + "reviews_data": [ |
| 261 | + { |
| 262 | + "google_id": "0x89c25bb5950fc305:0x330a88bf1482581d", |
| 263 | + "autor_link": "https://www.google.com/maps/contrib/112314095435657473333?hl=en-US", |
| 264 | + "autor_name": "Eliott Levy", |
| 265 | + "autor_id": "112314095435657473333", |
| 266 | + "review_text": "Very good local comfort fusion food ! \\nKimchi coleslaw !! Such an amazing idea !", |
| 267 | + "review_link": "https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s112314095435657473333!2s0x0:0x330a88bf1482581d?hl=en-US", |
| 268 | + "review_rating": 5, |
| 269 | + "review_timestamp": 1560692128, |
| 270 | + "review_datetime_utc": "06/16/2019 13:35:28", |
| 271 | + "review_likes": null |
| 272 | + }, |
| 273 | + { |
| 274 | + "google_id": "0x89c25bb5950fc305:0x330a88bf1482581d", |
| 275 | + "autor_link": "https://www.google.com/maps/contrib/106144075337788507031?hl=en-US", |
| 276 | + "autor_name": "fenwar1", |
| 277 | + "autor_id": "106144075337788507031", |
| 278 | + "review_text": "Great wings with several kinds of hot sauce. The mac and cheese ramen is excellent.\\nUPDATE:\\nReturned later to try the meatloaf slider, a thick meaty slice topped with slaw and a fantastic sauce- delicious. \\nConsider me a regular.\\ud83d\\udc4d", |
| 279 | + "review_link": "https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s106144075337788507031!2s0x0:0x330a88bf1482581d?hl=en-US", |
| 280 | + "review_rating": 5, |
| 281 | + "review_timestamp": 1571100055, |
| 282 | + "review_datetime_utc": "10/15/2019 00:40:55", |
| 283 | + "review_likes": null |
| 284 | + }, |
| 285 | + ... |
| 286 | + ] |
| 287 | +} |
| 288 | +``` |
| 289 | + |
| 290 | + |
| 291 | +Google Play Reviews response example: |
| 292 | +```json |
| 293 | +[ |
| 294 | + [ |
| 295 | + { |
| 296 | + "autor_name": "candice petrancosta", |
| 297 | + "autor_id": "113798143822975084287", |
| 298 | + "autor_image": "https://play-lh.googleusercontent.com/a-/AOh14GiBRe-07Fmx8MyyVyrZP6TkSGenrs97e1_MG7Z-sWA", |
| 299 | + "review_text": "I love FB but the app has been pissing me off lately. It keeps having problems. Now my public page for my business is not letting me see my notifications and it is very annoying. Also, it keeps saying that I have a message when I don\'t. That\'s been a probably for a very long time that comes and goes. I hate seeing the icon showing me that I have a message when I do not \\ud83d\\ude21", |
| 300 | + "review_rating": 1, |
| 301 | + "review_likes": 964, |
| 302 | + "version": "328.1.0.28.119", |
| 303 | + "review_timestamp": 1627360161, |
| 304 | + "review_datetime_utc": "07/27/2021 04:29:21", |
| 305 | + "owner_answer": null, |
| 306 | + "owner_answer_timestamp": null, |
| 307 | + "owner_answer_timestamp_datetime_utc": null |
| 308 | + }, |
| 309 | + { |
| 310 | + "autor_name": "Deren Nickerson", |
| 311 | + "autor_id": "117741211939002621733", |
| 312 | + "autor_image": "https://play-lh.googleusercontent.com/a/AATXAJwIXPpnodqFFvB9oQEsk8XYFqtkEcfDEmNr704=mo", |
| 313 | + "review_text": "Technical support is non-existent whatsoever. Currently hiding behind the guise of a lack of reviewers being able to sit and stare at a computer screen due to a pandemic that forces people to stay at and work from home. Using auto-bots to destroy people\'s only methods of communicating with the outside world. I bet Facebook literally has blood on their hands from all the people who have killed themselves due to having their accounts needlessly disabled for months. Also you can\'t remove the app..", |
| 314 | + "review_rating": 1, |
| 315 | + "review_likes": 225, |
| 316 | + "version": "328.1.0.28.119", |
| 317 | + "review_timestamp": 1627304448, |
| 318 | + "review_datetime_utc": "07/26/2021 13:00:48", |
| 319 | + "owner_answer": null, |
| 320 | + "owner_answer_timestamp": null, |
| 321 | + "owner_answer_timestamp_datetime_utc": null |
| 322 | + }, |
| 323 | + { |
| 324 | + "autor_name": "Tj Symula", |
| 325 | + "autor_id": "103540836420891624440", |
| 326 | + "autor_image": "https://play-lh.googleusercontent.com/a/AATXAJxW4-DAYNCAgj2OQ41lQadAQtBxX4G_Aqn-Urvc=mo", |
| 327 | + "review_text": "I have been logged into facebook for as long as I can remember, but I\'ve been booted somehow. I\'ve sent several emails with no response. All of my logins for multiple sites, I\'ve used the \\"login with facebook\\" option. I have no way to retrieve emails and passwords that I changed years ago, please help me fix this issue, its hindering my ability to use many online features on my phone.", |
| 328 | + "review_rating": 1, |
| 329 | + "review_likes": 181, |
| 330 | + "version": "328.1.0.28.119", |
| 331 | + "review_timestamp": 1627307359, |
| 332 | + "review_datetime_utc": "07/26/2021 13:49:19", |
| 333 | + "owner_answer": null, |
| 334 | + "owner_answer_timestamp": null, |
| 335 | + "owner_answer_timestamp_datetime_utc": null |
| 336 | + }, |
| 337 | + ... |
| 338 | + ] |
| 339 | +] |
| 340 | +``` |
| 341 | + |
| 342 | +Emails & Contacts Scraper response example: |
| 343 | +```json |
| 344 | +[ |
| 345 | + { |
| 346 | + "query": "outscraper.com", |
| 347 | + "domain": "outscraper.com", |
| 348 | + "emails": [ |
| 349 | + { |
| 350 | + |
| 351 | + "sources": [ |
| 352 | + { |
| 353 | + "ref": "https://outscraper.com/", |
| 354 | + "extracted_on": "2021-09-27T07:45:30.386000", |
| 355 | + "updated_on": "2021-11-18T12:59:15.602000" |
| 356 | + }, |
| 357 | + ... |
| 358 | + ] |
| 359 | + }, |
| 360 | + { |
| 361 | + |
| 362 | + "sources": [ |
| 363 | + { |
| 364 | + "ref": "https://outscraper.com/privacy-policy/", |
| 365 | + "extracted_on": "2021-11-18T12:51:39.716000", |
| 366 | + "updated_on": "2021-11-18T12:51:39.716000" |
| 367 | + } |
| 368 | + ] |
| 369 | + } |
| 370 | + ], |
| 371 | + "phones": [ |
| 372 | + { |
| 373 | + "value": "12812368208", |
| 374 | + "sources": [ |
| 375 | + { |
| 376 | + "ref": "https://outscraper.com/", |
| 377 | + "extracted_on": "2021-11-18T12:59:15.602000", |
| 378 | + "updated_on": "2021-11-18T12:59:15.602000" |
| 379 | + }, |
| 380 | + ... |
| 381 | + ] |
| 382 | + } |
| 383 | + ], |
| 384 | + "socials": { |
| 385 | + "facebook": "https://www.facebook.com/outscraper/", |
| 386 | + "github": "https://github.com/outscraper", |
| 387 | + "linkedin": "https://www.linkedin.com/company/outscraper/", |
| 388 | + "twitter": "https://twitter.com/outscraper", |
| 389 | + "whatsapp": "https://wa.me/12812368208", |
| 390 | + "youtube": "https://www.youtube.com/channel/UCDYOuXSEenLpt5tKNq-0l9Q" |
| 391 | + }, |
| 392 | + "site_data": { |
| 393 | + "description": "Scrape Google Maps Places, Business Reviews, Photos, Play Market Reviews, and more. Get any public data from the internet by applying cutting-edge technologies.", |
| 394 | + "generator": "WordPress 5.8.2", |
| 395 | + "title": "Outscraper - get any public data from the internet" |
| 396 | + } |
| 397 | + } |
| 398 | + ] |
| 399 | +``` |
0 commit comments