liuxurong
V2EX  ›  PHP

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

  •  
  •   liuxurong · Sep 23, 2013 · 5018 views
    This topic created in 4791 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
    binux
    Sep 23, 2013❤️1
    1
    curl_setopt($curlh, CURLOPT_INTERFACE, "xxx.xxx.xxx.xxx");
    liuxurong
    liuxurong
    OP
    Sep 23, 2013
    2
    @binux 顺便推荐一个cURL库吧,原生的太难看了。^_^
    binux
    binux
    Sep 23, 2013❤️1
    3
    @liuxurong 不会php
    marchtea
    marchtea
    Sep 23, 2013❤️1
    4
    @liuxurong 献丑自己写的小东西,简化了发送请求,只要写爬取后的处理类就可以了. https://github.com/marchtea/crawler_framework
    liuxurong
    liuxurong
    OP
    Sep 23, 2013
    5
    @marchtea 不错..

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

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

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

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