Giter VIP home page Giter VIP logo

google-map-scraping's Introduction

Google-Map-Scraping

Pretty easy to use... for me atleast, lol.

Well it's free and easy(really)

Just basic python knowledge required, unless you understand the below instructions!

How to use-

Open map.py

Edit the following lines-

  • Edit the line with location where your chromedriver.exe is
   service = Service(
        r"C:\Users\Vergil1000\Downloads\chromedriver-win64\chromedriver-win64\chromedriver.exe"
   )
  • Edit this linw with the file path of the excel sheet you want the data to be stored in
   file_path = r"C:\Users\Vergil1000\Downloads\AesCliMal.xlsx"
  • Edit the link with the link you need like this, for example if you need to scrape restraunts in Tokyo, Japan, the given code needs to be changed
    driver.get(
        f"https://www.google.com/maps/search/restaurants+near+New+York,+NY,+USA/@{x},{y},14z/data=!3m1!4b1?entry=ttu"
    )

For that the google map website link would be - https://www.google.com/maps/search/restaurants+in+Tokyo,+Japan/@35.6623336,139.6905891,13z/data=!3m1!4b1?entry=ttu So the above lines of code becomes -

    driver.get(
        f"https://www.google.com/maps/search/restaurants+in+Tokyo,+Japan/@{x},{y},14z/data=!3m1!4b1?entry=ttu"
    )
  • Edit the link with the link you need like this, for example if you need to scrape restraunts in Tokyo, Japan
    divx = driver.find_element(
        "xpath", "//div[@aria-label='Results for Aesthetic Clinic in kuala lumpur']"
    )

For that the the google map website link would be - https://www.google.com/maps/search/restaurants+in+Tokyo,+Japan/@35.6623336,139.6905891,13z/data=!3m1!4b1?entry=ttu So the above line becomes driver.get code becomes -

    divx = driver.find_element(
        "xpath", "//div[@aria-label='Results for restaurants in Tokyo, Japan']"
    )
  • Next you need to edit the x and y x and y is latitude and longitude
    x = 3.056058
    while x < 3.218067:
       y = 101.647851
       while y < 101.748686:
          y += 0.1
          lol(x, y)
       x += 0.1

Suppose you want to scrape the whole Tokyo, then open google maps and search tokyo

image image

From the image we took two points for which x=(35.547053,35.909462) and y=(138.945085,139.866140) So change in code will be-

    x = 35.547053
    while x < 35.909462:
       y = 138.945085
       while y < 139.866140:
          y += 0.1
          lol(x, y)
       x += 0.1

That's it for the changes in map.py

Run map.py using the following command in the termninal, open the terminal from the same folder

python map.py

Next open the excel and remove the duplicates

Next open whatlol.py

Edit the following lines-

  • Change the path with path in which you scraped and added the details map links using map.py - Line 9
    file_path = r"C:\Users\Vergil1000\Downloads\AesCliMal.xlsx"
  • Change the path with path of the excel file in which you want to store the details - Line 27
    file_path = r"C:\Users\Vergil1000\Downloads\testX.xlsx"
  • Change the path with path of chromedriver.exe - Line 27
    service = services.Chromedriver(
        binary=r"C:\Users\Vergil1000\Downloads\chromedriver-win64\chromedriver-win64\chromedriver.exe"
    )

Run whatlol.py using the following command in the termninal, open the terminal from the same folder python whatlol.py

And then you will have the list whatever you wanted to scrape

Hmm... I think I should make a video tut lol

google-map-scraping's People

Contributors

vergil1000x avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.