I have some code that relies on google maps to work. When you open Google Maps it opens a text-box. And the cursor is open to type. I am using the web browser module and the open function. How could I directly paste to the text-box?
Asked
Active
Viewed 480 times
-1
-
It would be helpful to show your code and see what you are missing. – Flair Nov 05 '20 at 03:42
-
1Nonetheless, if you want to automate pasting into the text-box, you might need to use Selenium: https://selenium-python.readthedocs.io/ If you want to see that in the browser, you would open the url returned by selenium in the webbrowser module. – Flair Nov 05 '20 at 03:45
-
2Alternatively, depending on your use case, perhaps you want to use the API directly instead of opening the browser: https://github.com/googlemaps/google-maps-services-python – Flair Nov 05 '20 at 03:47
-
I'm just a beginner and I have no idea what an API is – Samrath Chadha Nov 05 '20 at 04:00
-
1It sounds like a good time to learn what an API is in the first place. It stands for "Application Programming Interface": in general, it is a layer developed for developers like ourselves of toggle its services through programmatic means like Python. Rather than try to code up something that mimics what a regular person would do with with a browser, keyboard, and mouse, it is generally advisable to use a programming language or service to directly speak with the API. – Flair Nov 05 '20 at 04:04
1 Answers
1
Generally speaking, there is a way to open a website and paste using python with Selenium, and if you want to see it visually, you can use the web browser module in addition to Selenium.
Nevertheless, in your specific scenario, you want to access a Google service. I would recommend using its API over using Selenium and the webbrowser if you plan to use Google Maps continuously through automation. Google does own reCAPTCHA which Google will use against any bot-like activities. Again, I am not too sure what your usecase is, but I would generally use an available API over this Selenium automation.

Flair
- 2,609
- 1
- 29
- 41
-
I have some text which I want my code to open and search for it on google maps. You can't not give the exact location in the search bar. I want to put the text in the maps search area and see the options – Samrath Chadha Nov 05 '20 at 04:04
-
Sounds like the API documentation will answer your question: https://github.com/googlemaps/google-maps-services-python/blob/master/README.md#usage – Flair Nov 05 '20 at 04:06