I am currently in the process of learning about html, particularly the navigation and tracking of steps taken through a webpage. For the most part, many websites tend to use the variable ‘href’ as means for inferring the forwarding url. However I found that some websites do not do as such. Websites like X(Twitter) use PointerEvent’s to forward users on a webpage. As a result the forwarding url is obfuscated and cannot be viewed unless clicking into the link. Is there a way to extract data from a PointerEvent without having to interact with it?
Looking into an example found on X(Twitter), we find that certain elements like the time, or analytics utilize href while when clicking on the direct response, a PointerEvent is instead used.
using the devtools and the command monitorEvents($0, 'mouse')
in console after selecting the element in question, the monitored click produces the following result
PointerEvent {isTrusted: true, pointerId: 1, width: 1, height: 1, pressure: 0, …}
isTrusted
srcElement
baseURI: "https://x.com/elonmusk/status/1870581552775573641"
I am able to get to this point where I can find and isolate the element. But I don’t know what to do in regards to extracting from the PointerEvent.
from selenium import webdriver
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
driver = webdriver.Chrome()
driver.get('https://x.com/elonmusk/status/1869874908898967589')
xpath = "//div[contains(@tabindex,'0')]"
button = driver.find_element(By.XPATH, xpath)
4