Home > other >  opening a web browser and get url histories in python
opening a web browser and get url histories in python

Time:02-17

I am trying to make a python gui application.

What I want to do is to open a web browser by clicking a button. (Tkinter) When the web browser is opened, I do login. After logging it, it will redirect to the page. And that page url will consist of code as a param I need to use later in code.

I used webbrowser.open_new('') to open a web browser. But the limitation was it is only for opening.. there was no way to get the final redirected url I need.

Is there a way I can use to open a web browser and do something on that page and finally get that final url?

I am using python.

CodePudding user response:

There are a few main approaches for automating interactions with browsers:

  1. Telling a program how and what to click, like a human would, sometimes using desktop OS automation tools like Applescript
  2. Parse files that contain browser data (will vary browser to browser, here is Firefox)
  3. Use a tool or library that relies on the WebDriver protocol (e.g. selenium, puppeteer)
  4. Access the local SQLite database of the browser and run queries against it

Sounds like 3 is what you need, assuming you're not against bringing in a new dependency.

  • Related