1

I have been writing a simple code for a 5 days now which I am doing to improve my knowledge on web scraping using different packages, I have already wrote one that downloads all the URL's and has the choice of downloading all images or videos but when I visited 'https://www.pixwox.com/' it has a different html design where the urls are hidden so I googled and started using Selenium. It was all going well until I hit a wall and the limits of my python knowledge.

The error below is what I have been getting for about 4 of them days, sometimes the code will work fine and others it will show the error below:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <a class="downbtn" href="https://scontent-frt3-2.cdninstagram.com/v/t51.2885-15/313202955_1363105014229232_3490221399588911023_n.jpg?stp=dst-jpg_e35_p828x828&amp;_nc_ht=scontent-frt3-2.cdninstagram.com&amp;_nc_cat=108&amp;_nc_ohc=cB6igIdJd0UAX-sHSgL&amp;edm=ACWDqb8BAAAA&amp;ccb=7-5&amp;ig_cache_key=Mjk2MDU4OTQ5NjY4NTI4NzQwMQ%3D%3D.2-ccb7-5&amp;oh=00_AfAL1tPs2in8qcStQLZMdlDGZxdNRp5H5nnV4LpHWR07gg&amp;oe=6363A260&amp;_nc_sid=1527a3&amp;dl=1">...</a> is not clickable at point (156, 814). Other element would receive the click: <iframe id="h12_frm_bl9ib7ijd9k" scrolling="no" frameborder="0" width="100%" height="auto" marginheight="0" marginwidth="0" style="margin: 0px; padding: 0px; width: 100%; height: 84.6186px; overflow: hidden;"></iframe>
  (Session info: chrome=106.0.5249.119)

I know this means that the element I'm trying to click on has another element currently over top of it but currently even with stepping through the code I have not been able to see what is covering the element.

<a href="javascript:void(0);" class="more_btn" data-next="" data-maxid="2857001884859064580_460236112">View more</a>

My code is below, Please excuse the code for being messy, I am still learning.

import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait

option = webdriver.ChromeOptions()
option.add_argument(" — incognito")
#option.add_argument("start-maximized")
#option.add_argument("--window-size=1400,600")
user = input("User: ")
full_url = 'https://www.pixwox.com/profile/' + user + '/'
driver = webdriver.Chrome()
driver.get(full_url)
print(driver.title)
i = 0

while i < int(12):
    driver.execute_script("window.scrollTo(0,document.body.scrollHeight);")
    i += 1
    time.sleep(2)
    download_button = "downbtn"
    WebDriverWait(driver, 10).until(ec.presence_of_element_located((By.CLASS_NAME, download_button)))#.click()
    elements = driver.find_elements(By.CLASS_NAME, download_button)
    time.sleep(5)
    for element in elements:
        if element.text == 'Download': element.click()##### Added this sleep time ? time.sleep(2)
        print(f"Dowdloading: {element}")
        time.sleep(5)
else:
    pass

also I know compared to other peoples code this is quite basic but I am still learning so any help would be great to further my learning, please excuse the while loop, I didn't know how else to keep scrolling down without using it.

Fix's tried: Tried extending the sleep time to see whether it is a loading issue. Tried to scroll down to see if that was causing the issue but that raises another issue ie the view more button which is another obstacle. Stepped through the code using Thonny but was not able to find what is intercepting the element. Tried https://stackoverflow.com/questions/44724185/element-myelement-is-not-clickable-at-point-x-y-other-element-would-receiv Tried https://stackoverflow.com/questions/62260511/org-openqa-selenium-elementclickinterceptedexception-element-click-intercepted

I was expecting my code to be able to take a user input and download all images and videos on the whole page, currently it is very intermittent 99% of the time it downloads one image and then raises an 'ElementClickInterceptedException' error, that 1% downloads roughly 50 images and videos before raising the same error. I was also expecting it to scroll to the very bottom of the page so all images/videos load but the

<a href="javascript:void(0);" class="more_btn" data-next="" data-maxid="2857001884859064580_460236112">View more</a>

button stops the code from continuing.

Any help would be greatly appreciated.

Thank you

Ooo
  • 39
  • 9
  • 1
    _even with stepping through the code I have not been able to see what is covering the element_ The error message told you what other element is on top: `Other element would receive the click: – John Gordon Nov 04 '22 at 16:17
  • Thank you @JohnGordon How did I miss that, been looking at the code and the errors so long I missed what was causing it. Can I ask how I would overcome that issue? I have just found this but it keeps saying it has been deprecated. frame_ref = driver.find_elements_by_tag_name("iframe")[0] iframe = driver.switch_to.frame(frame_ref) So tried: driver.execute_script('arguments[0].click();', download_button) and it worked but continued to download the same img. – Ooo Nov 04 '22 at 17:48

0 Answers0