I would like to get the location (coordinates) in latitude and longitude from the clickable map on this web page and other similar pages. I am not sure how to go about this using rvest or a scraping package since the Google Maps link with coordinates as shown below only appears if I click on the Ver Mapa button in blue.
https://www.google.com/maps/embed/v1/search?q=-26.106150272877,-56.89951582606415&key=XXXXXXXXXXXXXX&zoom=14
under <div class="modal-body "id=map-canvas">
You are right, that the link is executed only when clicking the button. You also cannot access the link through rvest, because it is stored inside of a script. However, the script is loaded together with the HTML. Which means, it is accessible through the source-text of the website.
The website somehow had to know, where the coordinates are, to succesfully query google maps. Since you are only interested in the coordinates (I suppose), here is a code snippet that should get you started.
It downloads the html as text and through regex filters the relevant info from the stored google request.
You can play around with the regex here: https://regex101.com/r/XIagYl/1
What I did was just navigate to the source text of the website and ctrl-f "google.com/maps" and there the link was sitting in the script. :)
text <- httr::GET("https://clasipar.paraguay.com/inmuebles/propiedades-rurales/granja-sobre-asfalto-con-infraestructura-completa-2093966") %>% httr::content(as ="text")
stringr::str_extract_all(text,"(?<=q=).*(?=\\&key)")
Related
I have followed the tutorial on this website https://www.wp-tweaks.com/display-a-single-cell-from-google-sheets-wordpress/ which allows to dynamically display values from a Google spreadsheet on a WordPress page using a simple shortcode:
[get_sheet_value location="Cell Location"]
This solution worked seamlessly until a single page contained hundreds of those shortcodes (I basically need the whole content of the page to be editable via the spreadsheet). I started getting 100% Errors by API method (based on the Google Metrics) and the content was not displayed properly anymore. I realize that sending hundreds of read requests after each page load is not ideal and will inevitably affect the load performance and that Google imposes quota limits too. Is there a way to bypass this issue? For example by pulling the values from the Google spreadsheet only once a day. Unfortunately, I don't have much coding experience but I'm open to all solutions.
Thanks in advance!
You could publish the sheet to the web and embed it to your website:
In your sheet, go to File > Publish to the web
In the window that appears, click Embed.
Click Publish.
Copy the code in the text box and paste it into your site.
To show or hide parts of the spreadsheet, edit the HTML on your site.
It would look like this (click on Run code snippet):
<iframe src="https://docs.google.com/spreadsheets/d/e/2PACX-1vR3UbHTtAkR8TGNtXU3o4hzkVVhSwhnckMp7tQVCl1Fds3AnU5WoUJZxTfJBZgcpBP0VqTJ9n_ptk6J/pubhtml?gid=1223818634&single=true&widget=true&headers=false"></iframe>
You could try reading the entire spreadsheet as a JSON file and parse it within your code.
https://www.freecodecamp.org/news/cjn-google-sheets-as-json-endpoint/
I am scraping data from a site, and each item has a related document URL. I want to scrape data from that document, which is available is HTML format after clicking link. Right now, I've been using Google Sheets to ImportFeed to get the basic columns filled.
Is there a next step that I could do to go into each respective URL and grab elements from the document and populate the Google sheet with them? The reason I'm using the RSS feed (instead of python and BS is because they actually offer an RSS feed.
I've looked, and haven't found a question that matches mine specifically.
Haven't personally tried this yet but I've come across web scraping samples using App Script with the use of UrlFetchApp.fetch. You can also check the XmlService sample which is also related to scraping.
Anybody know how to create a proper URL to link to here.com maps, from my site? We use an extensive amount of API calls to embed the maps inside our site, but I want to send emails to people with a 'Click Here for directions' link inside pointing to here.com driving directions with the address or coordinates built into the URL.
Example:
With Google Maps, all we would have to do is make a simple link like this:
https://www.google.com/maps?saddr=32.5589671,-97.2586011&daddr=32.7787855,-97.4495476
Just pass along the variables saddr and daddr within the URL. I've tried everything to build a proper URL for here.com maps and it doesn't process it properly.
My best attempt was:
https://www.here.com/directions/drive/32.2589671,-97.4486011/Weatherford,_Texas?x=ep&map=30.38114,-89.89326,6,normal
But it does not process this URL properly and now I'm pretty much stuck, since I have tried everything that I know to try.
Something like https://www.here.com/directions/drive/start:lat1,lng1/end:lat2,lng2 seems to work.
The text before the colon provides the text of the start/end location
There should be absolutely no spaces between the latitude and longitude
If no map parameter is added, the map view defaults to show the whole route on a street map
If a map parameter of the form ?map=lat,lng,zoom,maptype is added, the map initially shows the map view specified, then moves to show the whole route - like this satellite map link
I've checked that the first link (without the map parameter) also works on a Windows Phone to forward to the HERE Maps app if it is installed. I've not tested what happens if the Android or iOS HERE Maps apps are installed on mobile. If the HERE Maps app is not present on a mobile, the site should forward to the m.here.com mobile friendly site.
Other endpoints will vary by device - the following are fine on tablets:
Parisian Restaurants https://www.here.com/discover/restaurant?map=48.85,2.35,15,normal
New York Traffic https://www.here.com/traffic/explore?map=40.7127,-74,15,normal
I'm currently creating an interactive web map using Google Maps Javascript API version 3. I'm not sure if this is possible but I would like to create a series of map layers consisting of different kml files that could be toggled from the side bar. I would also like to be able to access the individual points within the kmls so that when the user clicks on a particular point, photos, text etc. can be loaded outside the map window...
Any ideas on how to accomplish this? I've been searching for a while and only found ways of configuring the infowindow which I personally find unattractive...
There is a way to load KML into a google maps application natively, there is actually a pretty good example of how this is done here:
http://gmaps-samples-v3.googlecode.com/svn/trunk/layers/layers.html
One trick I will mention is that since the KML is downloaded to Google's servers in order to be rendered on the map, it must exist on a public facing web server somewhere, Google won't be able to access it from your local machine.
I found this tutorial which seems like it'll do the trick!
i am develope web application for factory i need to add google map with location of factory
in contact us web page.any help i am just beginging with web development
Easy way here does all the work for you.
Embedding a map into a website or blog
You can embed a simple map, a set of
driving directions, a local search, or
maps created by other users. Here's
how:
Ensure that the map you'd like to embed appears in the current map
display.
Click Link to this page in the top-right corner of the map.
In the box that pops up, copy the HTML under 'Paste HTML to embed in
website,' and paste it into the source
code of your website or blog.
If you'd like to adjust the size of the map before you embed it, just click
Customize and preview embedded map, select your preferred size, and take a
look at the preview map. Once you're happy with what you see, copy the HTML
that appears in the box at the bottom of the window.
Keep in mind that you won't be able to embed Traffic maps, Mapplets, and some
other Maps features.
Google Map API is just javascript. Which can be used in any web technology
follow this link you will get what you are looking for
http://code.google.com/apis/maps/documentation/javascript/
If your beginning, maybe you should try to learn web development first. Javascript, post/get mechanics, HTML/CSS validation. Tackling Google Maps integration right at the beginning of your learning process might slow down your project evolution. It's my opinion.
To learn google maps api, try to start at this address :
http://code.google.com/intl/en/apis/maps/documentation/javascript/introduction.html