国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

詳解puppeteer使用代理

2024-05-06 15:43:46
字體:
來源:轉載
供稿:網友

背景

在使用puppeteer進行訪問頁面的時候,有時候需要用到代理。

環境: centos 7

chrome 安裝

puppeteer使用chrome。 參考chrome的命令行使用方式。 在官網中沒看到說明,不過一般的執行文件都是支持help的。
在服務器上安裝chrome :

vim /etc/yum.repos.d/google-chrome.repo

添加內容

[google-chrome]name=google-chromebaseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearchenabled=1gpgcheck=1gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

安裝瀏覽器

yum -y install google-chrome-stable

說明: yum search chrome 可以查看供安裝的包

chrome 命令行代理

在shell中執行命令:

google-chrome -h

即可看到所有的命令選項,其中 OPTION 下面有代理添加的介紹以及示例:

 --proxy-server=host:port    Specify the HTTP/SOCKS4/SOCKS5 proxy server to use for requests.    This overrides any environment variables or settings picked via    the options dialog. An individual proxy server is specified    using the format:    [<proxy-scheme>://]<proxy-host>[:<proxy-port>]    Where <proxy-scheme> is the protocol of the proxy server, and is    one of:    "http", "socks", "socks4", "socks5".    If the <proxy-scheme> is omitted, it defaults to "http". Also    note that "socks" is equivalent to "socks5".    Examples:    --proxy-server="foopy:99"     Use the HTTP proxy "foopy:99" to load all URLs.    --proxy-server="socks://foobar:1080"     Use the SOCKS v5 proxy "foobar:1080" to load all URLs.    --proxy-server="socks4://foobar:1080"     Use the SOCKS v4 proxy "foobar:1080" to load all URLs.    --proxy-server="socks5://foobar:66"     Use the SOCKS v5 proxy "foobar:66" to load all URLs.    It is also possible to specify a separate proxy server for dif‐    ferent URL types, by prefixing the proxy server specifier with a    URL specifier:    Example:    --proxy-server="https=proxy1:80;http=socks4://baz:1080"     Load https://* URLs using the HTTP proxy "proxy1:80". And    load http://*     URLs using the SOCKS v4 proxy "baz:1080".  --no-proxy-server    Disables the proxy server. Overrides any environment variables    or settings picked via the options dialog.  --proxy-auto-detect    Autodetect proxy configuration. Overrides any environment vari‐    ables or settings picked via the options dialog.  --proxy-pac-url=URL    Specify proxy autoconfiguration URL. Overrides any environment    variables or settings picked via the options dialog.

其中 –proxy-server= 的值的格式是 [<proxy-scheme>://]<proxy-host>[:<proxy-port>]

其中 http 代理是不需要加 proxy-scheme ,以上的示例中顯示 socks 代理是需要添加scheme。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 卢氏县| 万宁市| 岳阳县| 巴马| 任丘市| 曲麻莱县| 咸阳市| 玉山县| 平遥县| 新乡市| 台江县| 田阳县| 吴堡县| 香港| 宜都市| 林甸县| 漠河县| 庆城县| 札达县| 兴海县| 岚皋县| 丹东市| 满洲里市| 介休市| 秭归县| 徐闻县| 白银市| 陈巴尔虎旗| 漳平市| 临高县| 汝阳县| 都江堰市| 合阳县| 维西| 海城市| 志丹县| 辉南县| 平湖市| 葵青区| 霍州市| 双桥区|