在wget和curl中使用代理


=Start=

缘由:

看到关注的博客中有一篇更新「wget和curl中使用代理」,觉得以后可能会用到,所以先测试、验证留待以后使用。

参考解答:
#直接在命令中指定代理
wget -e "use_proxy=yes" -e "http_proxy=10.1.4.43:8080" ixyzero.com
curl -x 10.4.90.9:8080 ixyzero.com

#通过设置环境变量使用代理
http_proxy="http://mycache.mydomain.com:3128"
http_proxy="http://myuser:[email protected]:3128"  #用户名/密码
export $http_proxy
wget ixyzero.com
curl ixyzero.com

curl -x "http://mydomain.com:3128" ixyzero.com
curl -x "http://myuser:[email protected]:3128" ixyzero.com

curl --user-agent "curl_with_proxy" -I http://ixyzero.com/blog/
curl --user-agent "curl_with_proxy" -I -x "10.4.90.9:8080" http://ixyzero.com/blog/

wget -U "wget_with_proxy" http://ixyzero.com/blog/regex.html
wget -U "wget_with_proxy" -e "use_proxy=yes" -e "http_proxy=10.4.90.9:8080" http://ixyzero.com/blog/regex.html

 

参考链接:

=END=

, ,

《“在wget和curl中使用代理”》 有 16 条评论

  1. 反击爬虫,前端工程师的脑洞可以有多大?
    http://litten.me/2017/07/09/prevent-spiders/
    `
    2. 后端与反爬虫
    后端目前比较常规单有效的防爬虫手段,比如:
    · User-Agent + Referer检测
    · 账号及Cookie验证
    · 验证码
    · IP限制频次

    而爬虫是可以无限逼近于真人的,比如:
    · chrome headless或phantomjs来模拟浏览器环境
    · tesseract识别验证码
    · 代理IP淘宝就能买到
    所以我们说,100%的反爬虫策略?不存在的。更多的是体力活,是个难易程度的问题。

    3. 前端与反爬虫
    3.1 font-face拼凑式
    3.2 background拼凑式
    3.3 字符穿插式
    3.4 伪元素隐藏式
    3.5 元素定位覆盖式
    3.6 iframe异步加载式
    3.7 字符分割式
    3.8 字符集替换式
    `

  2. 检测 Chrome Headless 模式的新方式
    https://antoinevastel.github.io/bot%20detection/2018/01/17/detect-chrome-headless-v2.html
    `
    # User agent (Old, 根据UA来进行判断)
    if (/HeadlessChrome/.test(window.navigator.userAgent)) {
    console.log(“Chrome headless detected”);
    }

    # Webdriver (New, 根据 navigator.webdriver 来进行判断)
    if(navigator.webdriver) {
    console.log(“Chrome headless detected”);
    }

    # Chrome (New, 根据 window.chrome 来进行判断)
    // isChrome is true if the browser is Chrome, Chromium or Opera
    if(isChrome && !window.chrome) {
    console.log(“Chrome headless detected”);
    }

    # Permissions (New, 根据 navigator.permissions 来进行判断)
    navigator.permissions.query({name:’notifications’}).then(function(permissionStatus) {
    if(Notification.permission === ‘denied’ && permissionStatus.state === ‘prompt’) {
    console.log(‘This is Chrome headless’)
    } else {
    console.log(‘This is not Chrome headless’)
    }
    });

    # Plugins (Old, 根据 navigator.plugins 来进行判断)
    if(navigator.plugins.length === 0) {
    console.log(“It may be Chrome headless”);
    }

    # Languages (Old, 根据 navigator.languages 来进行判断)
    if(navigator.languages === “”) {
    console.log(“Chrome headless detected”);
    }
    `

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注