浏览代码

设置user-agent

xyxie 1 年之前
父节点
当前提交
8659da0d43
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      metting.py

+ 5 - 3
metting.py

@@ -84,8 +84,10 @@ if __name__ == "__main__":
     options = webdriver.ChromeOptions()
     # options.add_argument("headless")
     options.add_argument('--headless')
-    options.add_argument('--disable-gpu')
-    options.add_argument('--no-sandbox')
+    options.add_argument(
+        '--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) '
+        'Chrome/111.0.0.0 Safari/537.36')
+    options.add_argument(" window-size=1920,1080")
     # options.add_argument(" window-size=1920,1080")
     s = Service(executable_path='/home/code/python/meeting_probabilities/chromedriver')
     # s = Service(executable_path='/Users/xi/Desktop/chromedriver')
@@ -93,7 +95,7 @@ if __name__ == "__main__":
     # driver.maximize_window()
     driver.get(
         'https://www.cmegroup.com/markets/interest-rates/cme-fedwatch-tool.html?redirect=/trading/interest-rates/countdown-to-fomc.html')
-    sleep(5)
+    sleep(2)
     btn_pop = get_element(driver, '/html/body/div[4]/div[3]/div/section/span')
     if btn_pop:
         btn_pop.click()