网格拦截的硒元素点击

时间:2020-05-18 19:16:55

标签: python selenium web-scraping

我正在尝试使用Selenium刮取Glassdoor的职位。我的脚本大约可以发布20篇文章,直到出现以下错误:

ElementClickInterceptedException: Message: element click intercepted: Element <li class="jl...</li> is not clickable at point (219, 699). Other element would receive the click: <div class="gdGrid noPad">...</div>

将获得点击的元素是围绕发布的网格。我很确定它不会掩盖帖子。我不确定为什么它随机不能单击下一个职位发布。我尝试更改slp.time,但没有任何效果。下面是我用来单击每个帖子的代码。

 #Going through each job in this page 
    job_buttons = driver.find_elements_by_class_name("jl")  #jl for Job Listing. These are the buttons we're going to click.


    for job_button in job_buttons:  

        print("Progress: {}".format("" + str(len(jobs)) + "/" + str(num_jobs)))
        if len(jobs) >= num_jobs:
            break

        job_button.click()  #You might 
        time.sleep(5)
        collected_successfully = False

        while not collected_successfully:
            try:
                company_name = driver.find_element_by_xpath('.//div[@class="employerName"]').text
                location = driver.find_element_by_xpath('.//div[@class="location"]').text
                job_title = driver.find_element_by_xpath('.//div[contains(@class, "title")]').text
                job_description = driver.find_element_by_xpath('.//div[@class="jobDescriptionContent desc"]').text
                collected_successfully = True
            except:
                time.sleep(5)

这是我得到错误的地方:

---> 60             job_button.click()  #You might
 61             time.sleep(5)
 62             collected_successfully = False

有解决方案吗?我正在使用Chrome

0 个答案:

没有答案