V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
liuxurong
V2EX  ›  PHP

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

  •  
  •   liuxurong · 2013-09-23 21:27:56 +08:00 · 3967 次点击
    这是一个创建于 3861 天前的主题,其中的信息可能已经有所发展或是发生改变。
    研究了一下。

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

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

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

    PHP已经有的那个Requests功能太少了 不好用。
    marchtea
        6
    marchtea  
       2013-09-23 23:22:57 +08:00   ❤️ 1
    @liuxurong 没用过..我去看看~研究研究看看怎么改进
    liuxurong
        7
    liuxurong  
    OP
       2013-09-23 23:33:44 +08:00
    @marchtea

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

    连模仿的PHP版也火,但功能太少了,建议封装cURL,必火。
    thbourlove
        8
    thbourlove  
       2013-09-27 13:17:09 +08:00   ❤️ 1
    不知道你说的功能太少了的那个库指的是哪一个?
    https://github.com/guzzle/guzzle 这个吗?
    是的话,我很好奇你觉得它缺什么功能?
    liuxurong
        9
    liuxurong  
    OP
       2013-09-27 17:45:06 +08:00
    @thbourlove
    https://github.com/rmccue/Requests
    我是说这个,guzzle 这个在普通的虚拟主机中应怎么安装呢?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2571 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 361ms · UTC 01:15 · PVG 09:15 · LAX 18:15 · JFK 21:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.