硒可以在python中查找iD的位置下载链接元素

发布于 2025-02-02 01:05:57 字数 745 浏览 2 评论 0原文

我正在尝试使Selenium自动上传和下载文件从 https:/https:/8mb.video/ 我可以上传该文件很好,但是在网站上处理后,硒无法找到下载链接的元素,即使给定的ID匹配HTML中的ID。这是我的代码:

driver = webdriver.Edge()

driver.get('https://8mb.video/')

driver.maximize_window()

driver.get("https://8mb.video/")
s = driver.find_element(By.XPATH, "//input[@type='file']")
s.send_keys("C:\\Users\\ijwto\\Desktop\\VUT\\bladee.mp4")

s = driver.find_element(By.ID, "rockandroll")
s.click()

try:
    element = WebDriverWait(driver, 30).until(
        EC.presence_of_element_located((By.ID, "dllink"))
    )
finally:
    print("nope")

我还尝试使用不起作用的element_to_be_clickable,并在HTML中检查了iFrame,但找不到任何东西。

任何帮助将不胜感激。

I'm trying to get Selenium to automate uploading and downloading files from https://8mb.video/ I can upload the file just fine, but after it processes on the site Selenium can't locate the element for the download link even though the ID given matches the ID in the html. Here's my code:

driver = webdriver.Edge()

driver.get('https://8mb.video/')

driver.maximize_window()

driver.get("https://8mb.video/")
s = driver.find_element(By.XPATH, "//input[@type='file']")
s.send_keys("C:\\Users\\ijwto\\Desktop\\VUT\\bladee.mp4")

s = driver.find_element(By.ID, "rockandroll")
s.click()

try:
    element = WebDriverWait(driver, 30).until(
        EC.presence_of_element_located((By.ID, "dllink"))
    )
finally:
    print("nope")

I've also tried using element_to_be_clickable which didn't work, and checked for iframes in the HTML and didn't find any.

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

锦欢 2025-02-09 01:05:57

为了下载文件需要element上单击在try Block中的

,如果在最后块中打印nope的意图是指示如果找不到元素,则可以在下添加而不是最后

注意: - WebDriverWait的等待时间可能会增加,以防您试图上传的视频很大,网站需要更多时间来处理它

的解决方案

driver = webdriver.Edge()
driver.get('https://8mb.video/')
driver.maximize_window()
driver.get("https://8mb.video/")
s = driver.find_element(By.XPATH, "//input[@type='file']")
s.send_keys("C:\\Users\\ijwto\\Desktop\\VUT\\bladee.mp4")
s = driver.find_element(By.ID, "rockandroll")
s.click()
try:
    element = WebDriverWait(driver, 30).until(
    EC.presence_of_element_located((By.ID, "dllink"))
    )
    element.click()
except:
  print("Nope")

In order to download the file need to click on the element in the try block

Also if the intention of printing Nope in the finally block is to indicate if the element was not found then it can be added under except instead of finally

Note:- The wait time for WebDriverWait may increase in case the video you are trying to upload is large and the site requires more time to process it

Your solution would like

driver = webdriver.Edge()
driver.get('https://8mb.video/')
driver.maximize_window()
driver.get("https://8mb.video/")
s = driver.find_element(By.XPATH, "//input[@type='file']")
s.send_keys("C:\\Users\\ijwto\\Desktop\\VUT\\bladee.mp4")
s = driver.find_element(By.ID, "rockandroll")
s.click()
try:
    element = WebDriverWait(driver, 30).until(
    EC.presence_of_element_located((By.ID, "dllink"))
    )
    element.click()
except:
  print("Nope")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文