最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

爬虫相关python+selenium在已经打开的浏览器上操作

运维笔记admin1浏览0评论

cmd运行

chrome.exe --remote-debugging-port=9222 --user-data-dir="C:\selenum\AutomationProfile"

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
 # -*- coding: utf-8 -*-
import random
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait














chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
chrome_driver = "C:/Users/MSI-CN/AppData/Local/Google/Chrome/Application/chromedriver.exe"
driver = webdriver.Chrome(chrome_driver, chrome_options=chrome_options)
print(driver.title)#目前网页的标题








browser = driver


url="这里输入要访问的目标网址"
browser.get(url)#括号里面输入要访问的网址




time.sleep(20)#暂停20s便于打开网页

发布评论

评论列表(0)

  1. 暂无评论