python chrome的自定义启动

# encoding:utf-8

"""
@version: python27
@author: fafa
@site: http://www.phpgao.com
@software: PyCharm Community Edition
@file: chromeserver.py
@time: 2018/7/29 0029 下午 5:24
"""
import time
from selenium import webdriver


class ChromeServerParse(object):
def __init__(self):
# chromedriver的路径
self.excute_path = "D:\\Python\\Python37\\Scripts\\chromedriver.exe"
# 指定chromedriver启动的端口
self.port = 8080
# 指定chromedriver service 启动的参数
self.service_args = ["lang=zh_CN.UTF-8", "--start-maximized", '--disable-infobars']
self.option = webdriver.ChromeOptions()
# 设置字符编码
self.option.add_argument("lang=zh_CN.UTF-8")
# 窗口最大化
self.option.add_argument("start-maximized")
# 隐身模式
self.option.add_argument("incognito")
# 阻止弹出框
self.option.add_argument('disable-infobars')

def start_chromedriver(self):
self.driver = webdriver.Chrome(
executable_path=self.excute_path,
port=self.port,
service_args=self.service_args,
chrome_options=self.option)
driver = self.driver
driver.get("http://www.baidu.com")
time.sleep(5)


if __name__ == '__main__':
ChromeServerParse().start_chromedriver()

转载于:https://www.cnblogs.com/tnyleyon/p/9387997.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值