Im building a simple web browser with Python, Gtk, and WebKitGtk. When trying to load youtube, i receive this error message:
console message: about:blank @0: Refused to display 'https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26app%3Ddesktop%26feature%3Dpassive%26hl%3Den%26next%3D%252Fsignin_passive&hl=en&passive=true&service=youtube&uilel=3' in a frame because it set 'X-Frame-Options' to 'DENY'.
my code (from a tutorial on webkitgtk):
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('WebKit', '3.0')
from gi.repository import Gtk, WebKit
class Main:
def __init__(self):
self.win = Gtk.Window()
self.win.set_position(Gtk.WindowPosition.CENTER)
self.win.set_title('window')
self.win.set_default_size(1200, 800)
self.btn_grid = Gtk.Grid()
self.btn_grid.set_column_spacing(10)
self.reload_button = Gtk.Button('Reload')
self.reload_button.connect('clicked', self.reload_window)
self.btn_grid.attach(self.reload_button, 0, 0, 1, 1)
self.url_entry = Gtk.Entry()
self.url_entry.set_hexpand(True)
self.url_entry.connect('activate', self.display_url)
self.btn_grid.attach(self.url_entry, 1, 0, 1, 1)
self.go_btn = Gtk.Button('Go')
self.go_btn.connect('clicked', self.display_url)
self.btn_grid.attach(self.go_btn, 2, 0, 1, 1)
self.main_box = Gtk.VBox()
self.main_box.pack_start(self.btn_grid, False, False, 0)
self.win.add(self.main_box)
self.webview = WebKit.WebView()
self.webview.connect('title-changed', self.title_update)
self.webview.load_uri("https://google.com")
self.scroll_area = Gtk.ScrolledWindow()
self.scroll_area.add(self.webview)
self.main_box.pack_start(self.scroll_area, True, True, 0)
self.win.connect('destroy', Gtk.main_quit)
def title_update(self, webview, frame, title):
self.win.set_title(f'window - {title}')
def display_url(self, event):
url = self.url_entry.get_text()
if url == '':
pass
else:
if "://" not in url:
url = f'https://{url}'
self.webview.load_uri(url)
self.webview.grab_focus()
def reload_window(self):
self.webview.reload()
def w_open(self):
self.win.show_all()
main_window = Main()
main_window.w_open()
Gtk.main()
How could i fix this problem? YouTube loads fine on other web browsers.
from How to fix refused to display url in a frame because it set x frame options to deny in webkitgtk python
No comments:
Post a Comment