当我尝试转到下一个帖子时,我尝试向下滚动并喜欢Instagram主页上的帖子,该帖子再次出现。我正在尝试使用下一篇文章的类名
这是我的代码
# Wait 3 second while the post-login page loads
time.sleep(3)
bot.find_element_by_xpath("//button[contains(text(), 'Not Now')]")\
.click()
time.sleep(3)
bot.find_element_by_xpath("//button[contains(text(), 'Not Now')]")\
.click()
time.sleep(3)
#Like the post
followButton = bot.find_element_by_class_name('fr66n')
followButton.click()
time.sleep(5)
#Go to the comment field
nex = bot.find_element_by_class_name('sH9wk')
time.sleep(1)
nex.click()
time.sleep(2)
#Go to next post ...but here it's again going to the first post
nex_post = bot.find_element_by_class_name('_9AhH0')
time.sleep(1)
nex_post.click()
答案 0 :(得分:0)
要向下滚动页面,只需键入以下代码
bot.execute_script('window.scrollTo(0,700)')
您可以输入向下滚动的大小,而不是700