Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wx, wx.html, requests, warnings
- from bs4 import BeautifulSoup
- class Test(wx.Frame):
- def __init__(self, parent, id):
- wx.Frame.__init__(self, parent, id, "Test App 2", (800, 800))
- warnings.filterwarnings("ignore", category = UserWarning, module = "bs4")
- self.panel = wx.Panel(self)
- self.panel.SetBackgroundColour("#FFFFFF")
- self.Centre()
- self.html = wx.html.HtmlWindow(self, pos = (0, 0), size = (700, 700))
- #show text contents of Wikipedia page
- self.URL = "https://en.wikipedia.org/wiki/Selena_Gomez"
- self.respond = requests.get(self.URL)
- self.soup = BeautifulSoup(self.respond.text)
- self.paragraphs = self.soup.find_all("p")
- self.text = ""
- for i in self.paragraphs:
- self.text = self.text + str(i.text.encode("utf8"))
- with open("text.html", "w") as text:
- text.write(self.text)
- self.html.LoadPage("text.html")
- def main():
- app = wx.App()
- frame = Test(None, -1)
- frame.Show()
- app.MainLoop()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement