国产探花免费观看_亚洲丰满少妇自慰呻吟_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。

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

圖片精選

主站蜘蛛池模板: 修武县| 琼海市| 绍兴县| 石景山区| 太白县| 凤庆县| 齐齐哈尔市| 广河县| 青浦区| 青河县| 保山市| 渑池县| 辽阳市| 于田县| 伊春市| 漯河市| 高密市| 阿拉善盟| 桦南县| 太仓市| 台前县| 晋城| 崇礼县| 太仆寺旗| 酉阳| 绥中县| 阿拉善右旗| 龙山县| 莱芜市| 莎车县| 丹江口市| 永丰县| 广西| 茶陵县| 富宁县| 延庆县| 永胜县| 邵阳市| 云和县| 卓资县| 宣武区|