美文网首页渗透安全
搭建自己的免费IP代理池

搭建自己的免费IP代理池

作者: 听闻不见 | 来源:发表于2017-12-28 12:14 被阅读995次

    参考链接:如何搭建自己的免费IP代理池

    环境

    python3.6

    下载安装

    https://github.com/jhao104/proxy_pool

    安装依赖

    pip install -r requirements.txt  #在下载项目的根目录下运行
    #如果安装有问题,可以根据requirements.txt的内容,手动安装依赖
    

    下载redis数据库

    windows下载地址:https://github.com/MicrosoftArchive/redis/releases
    启动redis:redis-server.exe redis.windows.conf(不要关闭)
    查看状态:redis-cli.exe
    
    Linux安装:sudo apt-get install redis-server
    启动redis:运行redis-server
    查看状态:redis-cli
    

    附上redis的相关资料:Redis 命令 | 菜鸟教程

    配置项目Config.ini

    注意格式的正确性,否则在项目运行时会各种报错,配置详情可参考这里

    [DB]
    ;Configure the database information
    ;type: SSDB/REDIS/MONGODB if use redis, only modify the host port,the type should be SSDB
    type = SSDB
    host = localhost
    port = 6379
    name = proxy
    
    [ProxyGetter]
    ;register the proxy getter function
    freeProxyFirst  = 1
    freeProxySecond = 1
    freeProxyThird  = 1
    freeProxyFourth = 1
    freeProxyFifth  = 1
    freeProxySixth = 1
    
    [HOST]
    ; API接口配置 http://127.0.0.1:5051
    ip = 0.0.0.0
    port = 5010
    

    运行

    # 如果你的依赖已经安全完成并且具备运行条件,可以直接在Run目录下运行main.py
    # 到Run目录下:
    >>>python main.py
    
    # 如果运行成功你应该看到有4个main.py进程
    
    # 你也可以分别运行他们,
    # 依次到Api下启动ProxyApi.py,Schedule下启动ProxyRefreshSchedule.py和ProxyValidSchedule.py即可.
    
    作者:小草好闲
    链接:https://zhuanlan.zhihu.com/p/31431224
    来源:知乎
    著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
    

    可能的报错

    • No module named 'markupsafe._compat'

    解决方法:重新安装markupsafe模块

    pip uninstall markupsafe
    pip install markupsafe
    

    直接用pip install markupsafe安装,可以会出现以下错误

    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6
    

    打开:D:\Anaconda2\envs\tool_env\Lib\site-packages\pip\compat,把__init__.py第75行return s.decode('utf_8'),把这一行替换为return s.decode('cp936')。这个是pip安装模块经常碰到的错误。

    使用

    启动过几分钟后就能看到抓取到的代理IP,你可以直接到数据库中查看,推荐一个SSDB可视化工具

    也可以通过api访问http://127.0.0.1:5010 查看。

    相关文章

      网友评论

        本文标题:搭建自己的免费IP代理池

        本文链接:https://www.haomeiwen.com/subject/bwimgxtx.html