centos7生產環境IP代理池(python)
阿新 • • 發佈:2018-01-15
.py openssl href snappy ttext ima sna make per 最近在研究爬蟲,需要在前面部署IP代理池,於是在開源中國找到proxy pool。可以自動抓取國內幾個免費IP代理網站的IP,並實時校驗IP的可用性,數據庫為SSDB。
IP代理池網站:
http://www.data5u.com/
http://www.data5u.com/free/
http://www.data5u.com/free/gngn/index.shtml
http://www.data5u.com/free/gnpt/index.shtml
http://www.66ip.cn/
http://www.ip181.com/
http://www.xicidaili.com/nn
http://www.xicidaili.com/nt
http://www.goubanjia.com/free/gngn/index.shtml
http://www.xdaili.cn/ipagent/freeip/getFreeIps?page=1&rows=10 8 cd /usr/src/
16 wget https://www.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz #安裝克隆工具git
17 tar -xzf git-2.9.5.tar.gz
18 cd git-2.9.5
19 make prefix=/usr/local/git all
20 make prefix=/usr/local/git install
21 echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
22 source /etc/bashrc
23 cd ..
24 git clone https://github.com/jhao104/proxy_pool.git #克隆proxy_pool
25 cd proxy_pool/
26 python –V #查看python版本2.7.5
27 yum -y install python34 #安裝python 3.4
28 wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
29 python3 get-pip.py #安裝pip
30 pip install -r requirements.txt #proxy_pool的安裝依賴包
32 cd /usr/local/
33 git clone https://github.com/ideawu/ssdb.git #克隆SSDB
34 cd ssdb
35 yum -y install autoconf
37 cd deps/snappy-1.1.0/ #編譯Snappy
38 ./configure
39 make
40 cd /usr/local/ssdb
41 make #安裝SSDB
42 make install
43 ln -sf /usr/local/ssdb/ssdb-server /usr/local/bin/ssdb-server
44 ln -sf /usr/local/ssdb/tools/ssdb-cli /usr/local/bin/ssdb-cli
45 ln -sf /usr/local/ssdb/tools/ssdb-dump /usr/local/bin/ssdb-dump
46 ln -sf /usr/local/ssdb/tools/ssdb-repair /usr/local/bin/ssdb-repair
47 ln -sf /usr/local/ssdb/tools/ssdb.sh /etc/rc.d/init.d/ssdb
48 chkconfig --add ssdb
49 chkconfig ssdb on
50 systemctl stop firewalld.service #關閉防火墻
51 systemctl disable firewalld.service
52 firewall-cmd --state
53 pip install --upgrade pyssdb
啟動proxy_pool順序
1 cd /usr/local/ssdb
2 ./ssdb-server -d ./ssdb.conf -s start
註意:ssdb服務在啟動的時候會在 var 目錄下生成一個ssdb.pid文件,當ssdb由於意外關閉的時候這個文件不會被刪除,因此當重新啟動ssdb服務的時候,會報誤,因此運行下面2行命令可以手動重啟。
./ssdb-server ssdb.conf -s stop
./ssdb-server -d ./ssdb.conf -s restart
IP代理池網站:
http://www.data5u.com/
http://www.data5u.com/free/
http://www.data5u.com/free/gngn/index.shtml
http://www.data5u.com/free/gnpt/index.shtml
http://www.66ip.cn/
http://www.ip181.com/
http://www.xicidaili.com/nn
http://www.goubanjia.com/free/gngn/index.shtml
http://www.xdaili.cn/ipagent/freeip/getFreeIps?page=1&rows=10
2 yum -y install git
3 yum –y install wget
4 yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
5 yum install gcc perl-ExtUtils-MakeMaker epel-release gcc-c++
16 wget https://www.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz #安裝克隆工具git
17 tar -xzf git-2.9.5.tar.gz
18 cd git-2.9.5
19 make prefix=/usr/local/git all
20 make prefix=/usr/local/git install
21 echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
22 source /etc/bashrc
24 git clone https://github.com/jhao104/proxy_pool.git #克隆proxy_pool
25 cd proxy_pool/
26 python –V #查看python版本2.7.5
27 yum -y install python34 #安裝python 3.4
28 wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
29 python3 get-pip.py #安裝pip
30 pip install -r requirements.txt #proxy_pool的安裝依賴包
32 cd /usr/local/
33 git clone https://github.com/ideawu/ssdb.git #克隆SSDB
34 cd ssdb
35 yum -y install autoconf
37 cd deps/snappy-1.1.0/ #編譯Snappy
38 ./configure
39 make
40 cd /usr/local/ssdb
41 make #安裝SSDB
42 make install
43 ln -sf /usr/local/ssdb/ssdb-server /usr/local/bin/ssdb-server
44 ln -sf /usr/local/ssdb/tools/ssdb-cli /usr/local/bin/ssdb-cli
45 ln -sf /usr/local/ssdb/tools/ssdb-dump /usr/local/bin/ssdb-dump
46 ln -sf /usr/local/ssdb/tools/ssdb-repair /usr/local/bin/ssdb-repair
47 ln -sf /usr/local/ssdb/tools/ssdb.sh /etc/rc.d/init.d/ssdb
48 chkconfig --add ssdb
49 chkconfig ssdb on
50 systemctl stop firewalld.service #關閉防火墻
51 systemctl disable firewalld.service
52 firewall-cmd --state
53 pip install --upgrade pyssdb
啟動proxy_pool順序
1 cd /usr/local/ssdb
2 ./ssdb-server -d ./ssdb.conf -s start
註意:ssdb服務在啟動的時候會在 var 目錄下生成一個ssdb.pid文件,當ssdb由於意外關閉的時候這個文件不會被刪除,因此當重新啟動ssdb服務的時候,會報誤,因此運行下面2行命令可以手動重啟。
./ssdb-server ssdb.conf -s stop
./ssdb-server -d ./ssdb.conf -s restart
3 cd /usr/src/proxy_pool/Run
4 python3.4 main.py #用python3.4啟動
客戶端訪問
http://ip:5010/
http://ip:5010/get (隨機調取一個IP及port)
http://ip:5010/get_all (調取所有可用IP及port)
具體使用請參考https://github.com/jhao104/proxy_pool
本文提供cenots7下的部署詳情,在此感謝contributor和j_hao104的無私奉獻!
centos7生產環境IP代理池(python)