-1

Is there a way so I can get the page content from the page I launch using:

import webbrowser

url = 'http://docs.python.org/'
# MacOS
#chrome_path = 'open -a /Applications/Google\ Chrome.app %s'

# Windows
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'

# Linux
# chrome_path = '/usr/bin/google-chrome %s'

webbrowser.get(chrome_path).open(url)

What I can see is that webbrowser does not seem to have any way to do that as I could do with Selenium. The problem is that I under some cicumstances can´t use Selenium on that page.

Is it possible to get the sessionID or windowID and try to connect with another library that would be able to get the content and even maybe press a row so it unfold that data?

user982455
  • 11
  • 3
  • The full documentation is [here](https://docs.python.org/3/library/webbrowser.html) and there's zero mention of any way of getting content. It says that the purpose of that module is to control web browsers. It seems to me that a lot of the library functions just send commands to the browser, there's pretty much nothing in terms of getting anything _back_ from the browsers. That's what tools like Selenium are for. If you aren't able to run it on a certain page, then you should figure out what the reason for that issue is. – Random Davis Mar 10 '23 at 22:15

1 Answers1

0

No, but there are many other ways to get web page content in python. For example

import urllib.request
page = urllib.request.urlopen(url)

or

import subprocess
response = subprocess.check_output(['curl', '-s', '-L', url])

or the Requests package

Mark Chackerian
  • 21,866
  • 6
  • 108
  • 99