What is the best way to extract hover-box information from an ajax website with Python?

Attempting to extract the dimensions for each cell on a map from this AJAX site, where details only appear when hovering over the cells has proven unsuccessful so far.

Using Python selenium webdriver and phantomJS did not yield any data when trying to load and extract the page source. Searching through Firebug for a .json file that could potentially hold the content also came up empty.

If possible, please check out the site and provide suggestions on how I can scrape the information from the hover-boxes that appear when pointing on each cell of the map.

P.S: Despite extensive research on various platforms including Stack Overflow, I have not been able to find a solution yet.

Answer №1

Instead of using AJAX, the page actually contains an svg object that includes a <g> element for each item (booth). To obtain the necessary information, you need to hover your mouse over this <g>. By utilizing the code below, you can access most of the item descriptions (approximately 2/3 of all g elements)… However, without knowing the context of the page, it is difficult to determine how regularly items appear:

from selenium import webdriver as web
from selenium.webdriver.common.action_chains import ActionChains
import time
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

driver = web.Chrome()
driver.maximize_window()
driver.get('http://www.aptaexpo.com/apta2017/public/eventmap.aspx?shmode=E&thumbnail=1')
time.sleep(5)
driver.find_elements_by_tag_name('polygon')[0].click() # [1] to choose another hall 
time.sleep(5)

list_of = driver.find_elements_by_xpath('//div[@class="leaflet-overlay-pane"]/*[name()="svg"]/*[name()="g"]')
for item in list_of:
    action = ActionChains(driver)
    action.move_to_element(item)
    try:
        description = wait(driver, 3).until(EC.visibility_of_element_located((By.XPATH, '//div[*[contains(text(), "Booth:")]]'))).text
        print(description)
        action.perform()
    except:
        action.perform()

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

Dotted JavaScript property within an object

Having trouble sorting an array of objects using the lodash orderBy function because it doesn't work when the iteratees contain a dot in the middle. For a better understanding of the issue, check out this plunker. plunker ar users = [ { 'us ...

The `innerHTML` function is responsible for closing HTML

My switch structure is set up as follows: switch (ratio) { case "16:9": imgContainer.innerHTML = '<img src="images/test-rata-de-aspect.jpg">' break case "4:3": imgContainer.innerHTML = '<img src="image ...

Using Ajax to submit two forms by clicking a submit button

Explanation : In this particular scenario, I am facing a challenge where I need to trigger another Ajax function upon successful data retrieval, but unfortunately, I am encountering some unknown obstacles. Code: ---HTML Form : <form accept-charset=" ...

I am unable to access Angular $scope in the HTML Template, although I can view it in the console log

I have been following some online tutorials and using the angularjs-template to start learning Angular. However, I am facing an issue where the page (html template) is not updating with the controller. It seems like there is a problem in how I've set ...

Generating a request to API using Express and create-react-app

I have my create-react-app running on localhost:3000 with a proxy set up in package.json to point to my server running at localhost:3001. { "name": "my-app", "version": "0.1.0", "private": true, "dependencies": { "axios": "^0.18.0", "react ...

The video is not appearing on mobile devices using Safari, Firefox, and Chrome, but it is displaying properly on desktop computers

My website has a video in the header that works fine on desktop but not on mobile. I am using next.js 13.4 and here is my code: <video id="background-video" autoPlay playsInline loop muted classN ...

Exploring the retrieval of JavaScript array elements from a ListModel within QML

Currently, I have some JavaScript data that consists of a list of objects containing other objects and arrays, which I want to append to a ListModel. This is what the structure looks like (assuming that the data is generated elsewhere and its structure sh ...

JavaScript innerHTML not functioning properly when receiving a response from a servlet

Can someone help me troubleshoot the code below? I'm receiving a response from the servlet, but I can't seem to display it inside the div. Here is the response: lukas requests to be your friend &nbsp <button value="lukas"onclick="accfr(th ...

Endless AngularJS loop using ng-view

I recently started experimenting with AngularJS for a new project I am working on, but I have encountered a problem when dealing with routes and views. For the sake of simplicity, I have minimized this example to its basic form, yet the issue persists. Th ...

How to update an object property in React using checkboxes

I am currently navigating the world of react and have encountered a challenging issue. I am in the process of developing an ordering application where users can customize their orders by selecting different ingredients. My approach involves using checkboxe ...

Javascript Solution for Testing Palindromes in a Linked List

I recently researched the solution for a palindrome problem using Javascript. There is one particular line of code that I am struggling to comprehend, and I'm hoping someone can shed some light on it for me. Here is the code snippet in question: thi ...

Error in scrolling previews detected in Jssor horizontal template maker

I've been working with Jssor Slider Maker and I'm using the vertical preview template that features two columns on the left side and a maximized image on the right side. After pulling the code from the developers pack, it includes scripts, CSS an ...

Highcharts displaying black color after AJAX refresh

Struggling to implement real-time data visualization using Highcharts, I found myself tired of sifting through documentation and feeling confused. My solution involves using AJAX refresh. When the page initially reloads, my chart renders properly. However, ...

No tests were run in 0.000 seconds during the execution of Python's unittest framework with Selenium

import unittest from selenium import webdriver from selenium.webdriver.common.keys import Keys class loginAvaliador(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome('/Users/r13/dev/chromedriver') def login_avalia ...

When I attempt to press the shift + tab keys together, Shiftkey is activated

Shiftkey occurs when attempting to press the shift + tab keys simultaneously $("#buttonZZ").on("keydown",function (eve) { if (eve.keyCode == 9 && eve.shiftKey) { eve.preventDefault(); $("#cancelbtn").focus(); } if (eve. ...

Tips for staying safe from UNLINK security vulnerabilities in PHP

I am currently using UNLINK in conjunction with PHP and AJAX. I understand that this approach is risky as it allows anyone to delete files. However, I require the use of AJAX because I do not want the page to reload when deleting files. My main concern is ...

Utilizing PUG for Iterating Through Multiple Items in Express Framework using JSON Data

I'm currently working on a small application using Express and PUG, aiming to achieve the following: https://i.stack.imgur.com/ZDyTK.png index.pug ul#restaurants-list li img.restaurant-img(alt='Mission Chinese Food', sr ...

Adjusting the overflow of a parent div based on the position of the div within it by scrolling

I'm trying to create a page with 3 different sections: <div class="container" id="main-container"> <div class="section" id="profile"> Hello World </div> <div class="section" id="projects"> Hello World 2 ...

What's the process for changing this arrow function into a regular function?

Hello from a child component in Vue.js. I am facing an issue while trying to pass data from the parent via sensorData. The problem lies in the fact that the arrow function used for data below is causing the binding not to occur as expected. Can anyone gu ...

I am experiencing some issues with React Router V4's functionality

I am currently developing a web application where I intend to showcase user details on the same page using routers when they are clicked. Below is my index.js file: window.React = React; render(<div> <Menu/><MainMenu/><App/>&l ...