1

I was wondering if it possible to access the html or body of a webpage after opening one using the webbrowser library?

import webbrowser

url = "https://testwebsite.com/"
chromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s"
testing = webbrowser.get(chromePath).open(url)
print(testing)

This works and gets to the webpage, but prints out True/False since it is a bool. Is there anyway to make it print out the html or body of that website?

Lux
  • 21
  • 2

1 Answers1

-1

To get the content of the webpage in python you can use urllib.

import urllib
googleContent = urllib.urlopen("http://google.com").read()

will save the content of google.com in the variable googleContent.

pptaszni
  • 5,591
  • 5
  • 27
  • 43