如何在python中使用Selenium Webdriver滚动Facebook页面?

时间:2019-07-23 08:06:30

标签: python selenium selenium-webdriver scroll selenium-chromedriver

我目前正在使用Selenium Web驱动程序来通过Facebook共享进行解析,但是我需要向下滚动以获取帖子。如何在Selenium中向下滚动。我正在使用python。

他一切都很好,但没有滚动

我要在facebook.com/lunch.pk上滚动查看他不滚动的帖子,请帮助我!

这是我的代码:

'''python

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import time

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("start-maximized")
driver = webdriver.Chrome()
driver.get("https://www.facebook.com/")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='email']"))).send_keys("03460522942")
time.sleep(2)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='pass']"))).send_keys("......")
time.sleep(.5)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='loginbutton']"))).click()
time.sleep(.5)
driver.get("https://www.facebook.com/lunch.pk")
WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='js_bz']"))).click()

'''

0 个答案:

没有答案