Extracting phone numbers from the 'Call' button in Google's local search results on mobile devices: A step-by-step guide

As I was conducting a search using a mobile User Agent for "chiropractors+New York+NY," Google presented me with a page that resembled the following:

https://i.sstatic.net/o5ewW.png

I am interested in programmatically extracting the phone number linked to from the Call button on the right side of the page. Despite my efforts using WebDriver (Python) with XPath, CSS selector, or ID, I have been unable to retrieve the desired information. Tools like Firebug and developer tools only show me the text 'Call' associated with the link. Additionally, attempting to copy the displayed number from Skype and locate it in the source code has not yielded any results. Is this task even feasible? For reference, the full HTML source can be accessed here.

Answer №1

In order to achieve this functionality in Java, it would look something like the code below:

List<WebElement> elements = driver.findElements(By.cssSelector("div[data-ajp-lr]"));
for (WebElement element : elements)
{
    System.out.println("Name: " + element.getAttribute("data-ajp-lr"));
    System.out.println("Contact number: " + element.findElement(By.cssSelector("div[data-link]")).getAttribute("data-link"));
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

We are unable to use Port 4444 as it is currently occupied. Kindly select an available port and indicate it using the -port option when starting the Selenium Grid

When trying to start the selenium grid hub, I encountered an error message in my CMD. The error reads as: The port 4444 is currently occupied, kindly select a different free port for the hub and specify it using the -port option. ...

Fill a dropdown menu with options from a JSON object, arranging them in ascending order

I have a JSON hash that I am using to populate a combo box with the following code: $.each(json_hash, function(key, value) { $("#select").append("<option value='" + key + "'>" + value + "</option>"); }); The functionality w ...

Getting the values of several labels using a class name - a comprehensive guide

Is there a way to retrieve the values of labels with the "timeAuction" class? I'm currently working on a JavaScript function that will target each label with the class name timeAuction and adjust its value. The number of labels with this class can va ...

WebDriverError: The preference value for network.http.phishy-userpass-length in Firefox is not valid: exceeds maximum allowed length

Attempting to initiate a new test case using gecko driver (v0.15) with a specific Firefox profile in Protractor 5.1.1. I created the profile based on this guidance: Set firefox profile protractor Upon starting the execution through the protractor configur ...

Automatically adjust the size of a parent div that houses two child divs

@media only screen and (min-width: 900px) { .map_left { display: inline; float:left; width: 100px; height: 100px; border: 3px solid green; } .map_right { display: inline; float:right; width: 100px; height: 100 ...

Enhanced Fancybox Version 2 adjusts iframe width to fit content

I have been attempting to adjust the width of the iframe in fancybox v2 to fit my content properly. However, every time I try, the content appears too large within the iframe and requires horizontal scrolling to view it all. My goal is to see the entire wi ...

Leveraging multiple ">" CSS selectors

Here is the HTML code to style: <table id="my-table"> <tr> <td> I would like to customize this </td> <td> <table> <tr> <td> Not looking to customize t ...

Angular and HTML calendar picker

Is there a way to display a date in an HTML input type="date based on a variable stored in my ts file? The variable ScreenDate is defined in my ts file. <input type="date" [(ngModel)]="ScreenDate"> I tried the above code but it did not work as exp ...

Clear, crisp images within a user interface web view

I currently have a webview that is set up to show an image, which can be seen in the code snippet provided below. Along with this image, there is also a [email protected] available in the bundle, sized at 128x128 for use specifically on the iPhone4 ...

Guide to executing protractor tests in Internet Explorer when protractor is set up globally

Currently, I have successfully installed Protractor globally and it is working well for Chrome tests. However, I am encountering issues while attempting to run tests on IE. It seems that Protractor is not recognizing the globally installed version of the I ...

Achieving the perfect alignment for expandable divs next to a consistently centered element using CSS

On my page, I want to ensure that the logo is always perfectly centered both horizontally and vertically when the page loads without any interactions. To achieve this, I used simple margin properties: margin: auto; position: absolute; top: 0; bottom: 0; ...

Is it normal not to see </head> and <body> tags in the page source code?

Looking at the source code of the page, you'll find something like this: <link rel="stylesheet" href="http://..."> <!-- analytics --> <script> ... Make sure the closing </head> tag and the opening <body> tag are positio ...

Is there a way to separate the string by using <br> as a delimiter and convert it into a list using Selenium

When displayed, my string appears as: line1 line2 line3 This is how it looks in HTML after being extracted with selenium: line1 <br> line2 <br> line3 <br> I attempted to convert this string into a list of 3 elements using the code below ...

Sometimes, in extremely rare instances, external stylesheets may fail to download or be properly applied

There have been very rare occurrences where major websites like Amazon and Facebook do not load a CSS file or apply the rules correctly, resulting in pages looking incomplete: I was recently asked to provide an internal explanation after receiving a compl ...

The Angular JS routes are not properly loading the required file from the provided TemplateURL when receiving a response from Node

I am trying to retrieve data from a MySQL database using node (routes.js) and have the results injected into club.html, which is then dynamically updated in index.html using ng-view. However, it seems that the JSON response from node is displaying directly ...

What is the reason behind Modernizr assigning a drag-and-drop class specifically to iOS devices?

I'm wondering why Modernizr assigns the draganddrop class to iOS devices. It seems challenging to drag and drop files in mobile Safari. Could this be a bug or intentional feature? ...

Is it possible to customize the borders of boxes in Google Charts Treemap?

Although this may seem like a minor issue, I can't find any information in the documentation. I'm currently using Google Charts treemap for monitoring a specific project. The problem I'm facing is that when all the parent level rectangles ar ...

How about "Switching Background Images Using a Click Trigger"?

I have a single web page with three different tabs. By clicking on each tab, the text displayed changes accordingly. I am looking to add three separate images for each tab so that when a user clicks on a specific tab, the image associated with it also chan ...

Ways to send data to a popup in svelte

Hey there, I could really use some assistance with my Svelte app. I'm trying to implement a modal and pass a parameter to the modal component in order to customize its content. However, when using the open() function of Modal, we only need to provide ...

Having trouble resizing divisions using three.js?

Three.js is an incredible library that offers thorough documentation and functions perfectly. I am currently attempting to display a plane with trackball control inside a div that resizes according to the window or browser size. However, I am encountering ...