我在打開所需的URL之前在chromedriver上安裝了Chrome擴展。 隨着擴展程序的安裝,它會打開一個提示「謝謝安裝」的選項卡。Python硒:如何關閉隨硒打開的選項卡自動打開的選項卡
擴展網址:https://chrome.google.com/webstore/detail/buyhatke/jaehkpjddfdgiiefcnhahapilbejohhj?hl=en
我想,因爲它不必要的數據加載到附近拓開的標籤。
代碼片段:
from selenium import webdriver
import time
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from bs4 import BeautifulSoup as soup
chrome_options = Options()
chrome_options.add_argument('load-
extension=C:\\Users\\SACHIN\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Extensions\\jaehkpjddfdgiiefcnhahapilbejohhj\\3.4.141_0')
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.implicitly_wait(30)
driver.get("https://paytm.com/shop/p/samsung-j3-pro-16-gb-black-MOBSAMSUNG-J3-PSTPL5914255C1B4E1C?src=grid&tracker=curated%7C%7Cmobile%20phones%7CCategory%20Grid%7C%2Fg%2Fmobile-accessories%2Fmobiles%2Fsmart-phones%7C66781%7C1%7C")
似乎是一個家庭作業的問題,因爲我看到張貼的關於同一個分機昨日OP的問題。 – demouser123