S
S
seosova2015-12-28 19:35:57
Python
seosova, 2015-12-28 19:35:57

How to find out what is the object on the site under the cursor in Python?

Hello. I want to make a script that would give out information about what object on the site is currently under the cursor. Is there any way to find out what object is under the cursor? For example, now the area is such and such a link, then we went to the picture, now we are leading to the input form, title, etc.? I understand that there are parsers, grabers, beauty soup and so on, but it's not a matter of finding an element and parsing it. I want to understand behind the movement what is now under the cursor. Is it even possible? At least in what direction to dig? Maybe this is easily implemented in JQuery, JavaScript and should I just connect them somehow to my scripts?
Thanks in advance, if at least the direction of study, tell me ...

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Valery Ryaboshapko, 2015-12-29
@seosova

You need JavaScript, pure JavaScript, or a library like jQuery.
With it, you hang an onhover event on each element in the DOM, and then do what you want in the handler function, for example, send a report to the server, or show XPath in the window. Just do not forget that some elements may already have their own onhover handler, you must remember to run it from your handler so as not to break anything.
With Python, for sure, you can also pile up some crutches (using the same Selenium), but it will be pitch darkness, I do not advise you to get involved.

D
Dark_O, 2015-12-28
@Dark_O

I think you need to look at how Adblock works, as there is a "Block ads on the site" function that does what you described.

A
Alexander, 2015-12-28
@syschel

JavaScript. Because python is a server language, and the server does not know what is happening in the browser. You need to use exactly what is performed in real time on the user side, that is, in the browser.

G
gassmonkey, 2015-12-28
@gassmonkey

And the inspector in the browser does not suit you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question