[英]Using python/selenium to target the likes scroll bar in instagram
我正在尝试滚动浏览当我在 Instagram 上点击喜欢的照片并获取喜欢每张照片的个人资料时出现的滚动条。 不幸的是,我无法定位对话框。
这是html代码:
<div class="pbNvD fPMEg " role="dialog">
<div class=" Igw0E IwRSH eGOV_ vwCYk"style="max-height: 356px; min-height: 200px;">
<div style="height: 356px; overflow: hidden auto;">
</div>
</div>
<div>
这是我到目前为止尝试过的代码,但虽然没有错误,但它不会滚动:
fBody = driver.find_element_by_xpath("//div[@class='pbNvD fPMEg ']")
scroll = 0
fList = []
n = 0
while n < 5: # scroll 5 times
n = n +1
driver.execute_script('arguments[0].scrollTop = arguments[0].scrollTop + arguments[0].offsetHeight;', fBody)
time.sleep(1)
如果您总是想滚动到页面末尾,最简单的方法是:
fBody.send_keys(Keys.END)
如果您只想向下滚动到一页,则使用另一个:
fBody.send_keys(Keys.PAGE_DOWN)
更多细节在这里: https : //stackoverflow.com/a/27760083/6042903
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.