I am trying to scrape dynamic information from an HTML site. Since the place that I work from is a bank, I can only use the libraries they have certified as safe. Selenium and PyQt are not an option so I must work with wx.html2.
I found this code snippet:
import wx
import wx.html2
class MyBrowser(wx.Dialog):
def __init__(self, *args, **kwds):
url = "http://www.exampleurl.com"
wx.Dialog.__init__(self, *args, **kwds)
sizer = wx.BoxSizer(wx.VERTICAL)
self.browser = wx.html2.WebView.New(self, url=url)
sizer.Add(self.browser, 1, wx.EXPAND, 10)
self.SetSizer(sizer)
self.SetSize((700, 700))
if __name__ == '__main__':
app = wx.App()
dialog = MyBrowser(None, -1)
dialog.Show()
app.MainLoop()
This allows me to open a web dialog and see the desired content. What I want is to used the wx.html2.WebView GetPageSource() method.
https://wxpython.org/Phoenix/docs/html/wx.html2.WebView.html
I have tried it in the MyBrowser class as:
class MyBrowser(wx.Dialog):
def __init__(self, *args, **kwds):
url = "http://www.exampleurl.com"
wx.Dialog.__init__(self, *args, **kwds)
sizer = wx.BoxSizer(wx.VERTICAL)
self.browser = wx.html2.WebView.New(self, url=url)
sizer.Add(self.browser, 1, wx.EXPAND, 10)
self.SetSizer(sizer)
self.SetSize((700, 700))
print(wx.html2.WebView.GetPageContent(self.browser))
Any idea on how to get this source HTML or an insight on this class would be appreciated. Thanks.