Commit 46165fef authored by liyang's avatar liyang

feat:facebook 适配windows

parent c648843b
import json import json
import platform
import time import time
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from utils.Logger import log from utils.Logger import log
...@@ -29,7 +30,7 @@ from selenium.webdriver.support import expected_conditions as EC ...@@ -29,7 +30,7 @@ from selenium.webdriver.support import expected_conditions as EC
def reptile(browser=None, search_word=""): def reptile(browser=None, search_word=""):
print(f"搜索词:{search_word}") print(f"搜索词:{search_word}")
url = "https://www.facebook.com/" url = "https://www.facebook.com/"
browser = browser or create(no_headless=False,using_user_data=True) browser = browser or create(no_headless=True,using_user_data=True)
# 打开网页 # 打开网页
browser.get(url) browser.get(url)
try: try:
...@@ -41,6 +42,9 @@ def reptile(browser=None, search_word=""): ...@@ -41,6 +42,9 @@ def reptile(browser=None, search_word=""):
# 获取登录按钮 # 获取登录按钮
button_login = browser.find_element('xpath', "//button[@name='login']") button_login = browser.find_element('xpath', "//button[@name='login']")
button_login.click() button_login.click()
if platform.system() == "windows":
time.sleep(3)
else:
wait = WebDriverWait(browser,10) wait = WebDriverWait(browser,10)
wait.until(EC.presence_of_element_located((By.XPATH,"//div[@role='main']"))) wait.until(EC.presence_of_element_located((By.XPATH,"//div[@role='main']")))
except: except:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment