-2

To parse the site, I need to collect information in real time from the page I am on. And I need to get a link, which is always completely different. I did this through the mouse library and keyboard, but this is not very convenient because it depends heavily on coordinates. take a screenshot of the screen and use "openСМ" to recognize the text in the url address, but this is too much. Is there any easy way to get the url from the browser in real time

I tried to find an answer to this question on the Internet, but I didn’t see any simple answer, for example, using some method of some library

Klonmine
  • 21
  • 1

2 Answers2

0

Make chrome javascript extension. With correct event listeners and queries. You can access those data

If only url. Window.location.url

0

Thanks everyone, it looks like I found the answer myself. If someone needs to get the url of the page you are currently on, then you need to use the "keyboard" library and the code will look like this:

keyboard.press_and_release('Ctrl + L')
keyboard.press_and_release('Ctrl + C')

keyboard shortcut ctrl+l allows you to select a url

Klonmine
  • 21
  • 1
  • 1
    I forgot to add that in order to save this url in some kind of variable, you need to use the library pyperclip – Klonmine Aug 06 '23 at 23:06