liuxurong
V2EX  ›  PHP

一个VPS送了两个IP,PHP 做爬虫时如何切换这两个IP抓取远程的东西?

  •  
  •   liuxurong · Sep 23, 2013 · 4790 views
    This topic created in 4659 days ago, the information mentioned may be changed or developed.
    研究了一下。

    file_get_contents() : 不行哦..
    fsockopen:没有这功能哦..
    cURL: 好像也没这个功能

    求指点。
    9 replies    1970-01-01 08:00:00 +08:00
    binux
        1
    binux  
       Sep 23, 2013   ❤️ 1
    curl_setopt($curlh, CURLOPT_INTERFACE, "xxx.xxx.xxx.xxx");
    liuxurong
        2
    liuxurong  
    OP
       Sep 23, 2013
    @binux 顺便推荐一个cURL库吧,原生的太难看了。^_^
    binux
        3
    binux  
       Sep 23, 2013   ❤️ 1
    @liuxurong 不会php
    marchtea
        4
    marchtea  
       Sep 23, 2013   ❤️ 1
    @liuxurong 献丑自己写的小东西,简化了发送请求,只要写爬取后的处理类就可以了. https://github.com/marchtea/crawler_framework
    liuxurong
        5
    liuxurong  
    OP
       Sep 23, 2013
    @marchtea 不错..

    如果写成像Python Requests库那样就好了。

    PHP已经有的那个Requests功能太少了 不好用。
    marchtea
        6
    marchtea  
       Sep 23, 2013   ❤️ 1
    @liuxurong 没用过..我去看看~研究研究看看怎么改进
    liuxurong
        7
    liuxurong  
    OP
       Sep 23, 2013
    @marchtea

    Python最火的库之一 ^_^
    http://cn.python-requests.org/en/latest/

    连模仿的PHP版也火,但功能太少了,建议封装cURL,必火。
    thbourlove
        8
    thbourlove  
       Sep 27, 2013   ❤️ 1
    不知道你说的功能太少了的那个库指的是哪一个?
    https://github.com/guzzle/guzzle 这个吗?
    是的话,我很好奇你觉得它缺什么功能?
    liuxurong
        9
    liuxurong  
    OP
       Sep 27, 2013
    @thbourlove
    https://github.com/rmccue/Requests
    我是说这个,guzzle 这个在普通的虚拟主机中应怎么安装呢?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3034 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 08:12 · PVG 16:12 · LAX 01:12 · JFK 04:12
    ♥ Do have faith in what you're doing.