我正在尝试截取 selenium 页面的屏幕截图并将其显示在我的 tkinter gui 的画布上,但由于某种原因我收到错误消息:
TypeError: __str__ returned non-string (type bytes)
这是代码,感谢您提前提供帮助
from tkinter import *
import tkinter as tk
import time
from selenium import webdriver
root = tk.Tk()
root.geometry('700x700')
def picture():
browser = webdriver.Chrome('C:\\Users\\Downloads\\chromedriver_win324\\chromedriver.exe')
browser.get('https://google.co.uk')
fil = browser.get_screenshot_as_png()
img = PhotoImage(fil)
canvas = Canvas(root, width=300,height=300)
canvas.place(x=12.5,y=450)
canvas.create_image(20,20, image=img)
Button(root, text='Start', command=lambda: picture()).pack()
root.mainloop()
蓝山帝景
相关分类