python - Python, webkit2 gtk - 如何在 python 程序中使用 webkit 中的代理
问题描述
这是我迄今为止所拥有的一个简单的网络浏览器现在我希望使用代理加载页面。我检查了https://webkitgtk.org/reference/webkit2gtk/unstable/WebKitWebContext.html#webkit-web-context-set-network-proxy-settings但不明白如何实现这一点。
#!/usr/bin/python3
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('WebKit2', '4.0')
from gi.repository import Gtk, WebKit2
class Window(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Simple browser") # Name the app
self.appWebView = WebKit2.WebView() # Added self to webkit view because it's good practice to assign variables to the class and not
self.appWebView.load_uri("http://www.google.com")
self.add(self.appWebView)
mainWindow = Window()
mainWindow.connect("delete-event", Gtk.main_quit) # This line quits the GTK loop when the window is closed
mainWindow.show_all() # Changed to mainWindow because Window is our class and mainWindow is our instance of the class that's running
Gtk.main()
希望有人可以通过示例帮助我如何做到这一点。非常感谢。
解决方案
推荐阅读
- mysql - 我已阅读数据库名称 WAJ_Project_Management。但我在该表中有错误。错误调用 ERROR 1215 (HY000): 无法添加外键约束
- angular - 在 Angular 8 中刷新页面时 CSS 未正确加载
- amazon-web-services - 无法将 JSON 从 API Gateway 传递到 SQS
- java - 为什么我的 AlertDialog 一直显示?
- git - 找到一种方法来管理我的项目的子目录
- file - 如何恢复 NTFS 文件表?
- java - 将java类与数据库连接
- java - 我添加到程序中的方法未返回所需的结果
- r - “lib64/R/include:没有这样的文件或目录”错误
- android - 在一个广播接收器上设置 2 个警报