【发布时间】:2021-04-27 11:08:10
【问题描述】:
所以,我想创建一个机器人,在 Reddit 上下载多个(全部)模因(图像的类是 _2_tDEnGMLxpM6uOa2kaDB3 ImageBox-image media-element _1XWObl-3b9tPy64oaG6fax)
好的,这是我的代码:
from selenium import webdriver
import time
import pyautogui
import urllib
browser = webdriver.Chrome(executable_path=r"chromedriver_win32/chromedriver.exe")
browser.get('https://www.reddit.com/r/memes/new/')
time.sleep(3)
pyautogui.click(375,187)
findclass = browser.find_elements_by_class_name("_2_tDEnGMLxpM6uOa2kaDB3 ImageBox-image media-element _1XWObl-3b9tPy64oaG6fax")
for i in findclass:
try:
src = findclass.get_attribute('src')
urllib.urlretrieve(src, "meme.png")
print("found it!")
except Exception as e:
print(e)
在我的输出中什么都没有,没有错误什么都没有 idk 出了什么问题 xd ???
【问题讨论】:
-
你试过只安装一个吗?从小处着手,它可能看不到图像。
标签: python python-3.x selenium bots