|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- import requests, cv2
- import fake_useragent as fakeua
- import numpy as np
- from bs4 import BeautifulSoup
- from io import BytesIO
- url = "https://xxxxx.com.cn"
- ua = fakeua.FakeUserAgent()
- headers = {
- "User-Agent": ua.googlechrome
- }
- response = requests.get(url, headers=headers)
- soup = BeautifulSoup(response.content.decode(response.encoding), 'lxml')
- imgs = soup.select('.fl_icn_g')
- for img in imgs:
- url2 = img.a.img['src']
- image = requests.get("https://xxxxx.com.cn/" + url2, headers=headers)
- image = np.array(bytearray(image.content), dtype=np.uint8)
- image = cv2.imdecode(image, cv2.IMREAD_COLOR)
- cv2.namedWindow('wt', cv2.WINDOW_NORMAL)
- cv2.imshow('My1919810', img)
- cv2.waitkey()
- break
复制代码- >>>
- ===================== RESTART: C:\Users\ASUS\Desktop\111.py ====================
- Traceback (most recent call last):
- File "C:\Users\ASUS\Desktop\111.py", line 20, in <module>
- cv2.namedWindow('wt', cv2.WINDOW_NORMAL)
- cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1255: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvNamedWindow'
复制代码
是opencv不支持win11吗,gpt说opencv的官方文档提到opencv支持windwos10
代码中使用的窗口名称和等待用户按键的时间有误,请将 cv2.imshow('My1919810', img) 改为 cv2.imshow('wt', image),并将 cv2.waitkey() 改为 cv2.waitKey(0)
|
|