在 Quora 上,我想滚动到单击查看赞成票按钮时得到的窗口底部,以获取所有赞成票的姓名,向下滚动标准浏览器窗口的代码似乎不适用于覆盖窗口,有什么建议吗?这是我的向下滚动功能代码和单击“查看支持者”按钮的代码:
def scrolldown(browser):
src_updated = browser.page_source
src = ""
while src != src_updated:
src = src_updated
time.sleep(5)
browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(5)
src_updated = browser.page_source
#if (DEBUG): print ("window maximized...")
return browser
browser.get('https://www.quora.com/What-is-it-like-to-regret-having-children')
for p in browser.find_elements_by_class_name('AnswerVoterListModalLink'):
time.sleep(5)
p.click()
time.sleep(5)
browser=scrolldown(browser)
time.sleep(5)
c=0
for div in upvoter_name :#browser.find_elements_by_class_name('author_info'):
list_of_upvoters.append(div.find_element_by_class_name('user').text)
c+=1
print("number of upvoters for this answer is :" + str(c))