我正在使用selenium抓取tradingview战略订单,我能够使用我的凭据连接到tradingview,尽一切努力进入订单页面。为了刮取订单,我必须向下滚动所有订单,我像这样递归地进行操作
def checkIfBottomOfViewReached(driver, element):
return driver.execute_script("if (arguments[0].scrollHeight == arguments[0].offsetHeight + arguments[0].scrollTop) { return true; } else { return false; }", element)
def scrollToElement(driver, element):
driver.execute_script("arguments[0].scrollIntoView();", element)
def printTableDataRecursively(element_table_rows):
global count
global table_view
is_reached = checkIfBottomOfViewReached(driverweb, table_view)
for el in element_table_rows:
count = count + 1
if count == len(element_table_rows) and is_reached is not True:
count = 0;
scrollToElement(driverweb, el)
rows = driverweb.find_elements_by_css_selector("div.report-content.trades .report-data .table-wrap table tbody")
element_to_remove = rows[0]
rows.remove(element_to_remove)
printTableDataRecursively(rows)
else:pass
到达末尾后,我需要获取添加到表中的新订单,以便在管道中使用它们,有没有办法只获取随时间推移使用python和selenium添加的最后一项? 如何使用selenium处理动态添加的数据
目前没有回答
相关问题 更多 >
编程相关推荐