Python selenium 模拟ip 代理ip地址访问

版权声明:本文为博主原创文章,未经博主允许不得转载 https://blog.csdn.net/qq_24909089/article/details/88821504

本章讲述Google Chrome浏览器方法

1、安装python与selenium模块

2、非常重要:查看Chrome版本

3、非常重要:下载对应的chromedriver程序

官网地址-需要翻墙:https://sites.google.com/a/chromium.org/chromedriver/downloads

这边是我下载好的包:https://download.csdn.net/download/qq_24909089/11061282

4、查找可用代理ip

推荐网址:https://www.xicidaili.com/nt/

5、贴代码

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Author:
# @Date  : 2019/3/26

from selenium import webdriver

# 设置谷歌浏览器的一些选项
options = webdriver.ChromeOptions()

options.add_argument("--proxy-server=http://113.200.214.164:9999")

# executable_path 写自己 chromedriver 解压后所在目录地址

browser = webdriver.Chrome(executable_path='/Users/Python/chromedriver', chrome_options=options)

browser.get("http://httpbin.org/ip")

print(browser.page_source)

6、运行效果:

猜你喜欢

转载自blog.csdn.net/qq_24909089/article/details/88821504
今日推荐