python3webspider / adslproxy Goto Github PK
View Code? Open in Web Editor NEWAdsl Proxy Pool
License: MIT License
Adsl Proxy Pool
License: MIT License
在 sender.py 中的 run() 里面如果 subprocess.getstatusoutput(DIAL_BASH) 执行提前结束,就会陷入无限拨号的问题。比如 subprocess.getstatusoutput(DIAL_BASH) 执行完了,拨号还没成功,还没获取到IP地址,需要等个10秒才获取到IP地址。此时提前进入 self.extract_ip() 获取IP,就会获取不到,ip 这个变量为空,进入 else 语句,马上重新执行 self.run() 重新拨号。。
建议或者在 self.extract_ip() 里面加入一个 while 等待时间 ,比如每 while 60秒,每检查一次就减1,然后sleep 1秒。有个60秒等待时间,再返回IP,或许会比较好。比如这样:
def extract_ip(self):
"""
获取本机IP
:param ifname: 网卡名称
:return:
"""
WAIT_TIME = 60
while WAIT_TIME:
(status, output) = subprocess.getstatusoutput('ifconfig')
if not status == 0: return
pattern = re.compile(DIAL_IFNAME + '.*?inet.*?(\d+\.\d+\.\d+\.\d+).*?netmask', re.S)
result = re.search(pattern, output)
if result:
# 返回拨号后的 IP 地址
return result.group(1)
WAIT_TIME -= 1
time.sleep(1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 572, in execute_command
connection.send_command(*args)
File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 563, in send_command
self.send_packed_command(self.pack_command(*args))
File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 538, in send_packed_command
self.connect()
File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 442, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 104 connecting to <redis_host>:6379. Connection reset by peer.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 439, in connect
sock = self._connect()
File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 494, in _connect
raise err
File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 482, in _connect
sock.connect(socket_address)
ConnectionResetError: [Errno 104] Connection reset by peer
与issue#3同理 当redis和vps网络不稳定的时候操作redis集合会导致程序中断
Pypi安装的adslproxy的 RedisClient函数和github版有差别,主要体现在存取函数上(key存储和hash存储),所以建议大家使用的时候动态服务器和Redis主机上最好统一,否则获取proxy时会出错
当前代码IP代理存储用的是hset方法,pip安装的版本获取代理没有用对应的hget,用的是get,pip版本是不是没有更新,导致每次获取都是空。
我的解决办法是根据最新代码的RedisClient.random()方法获取,没有通过pip安装的获取
输入ls命令后只有anaconda-ks.cfg这一个文件
受崔大启发,写了个adsl拨号代理池管理工具,欢迎吐槽。
https://github.com/osof/awesome-proxy
优点:
1、一键部署、免维护!
2、动态更新配置
3、动态管理主机
4、高可用、高匿名、高性能
因为我刚入行代理这块
1.请问大神有没有专业的QQ群
2.请问大神有没有如题的相关专业资料
3.我是做java的,请问有没有相关专业资料
你好,麻烦请教一下,我将ADSL_CYCLE设置为21600秒后,时间到达了,线程却没有循环执行,是什么原因,平时都在写Java,不知道Python是怎么休眠的
while True:
print('ADSL Start, Remove Proxy, Please wait')
self.remove_proxy()
(status, output) = subprocess.getstatusoutput(ADSL_BASH)
if status == 0:
print('ADSL Successfully')
ip = self.get_ip()
if ip:
print('Now IP', ip)
print('Testing Proxy, Please Wait')
proxy = '{ip}:{port}'.format(ip=ip, port=PROXY_PORT)
if self.test_proxy(proxy):
print('Valid Proxy')
self.set_proxy(proxy)
print('Sleeping')
time.sleep(ADSL_CYCLE)
else:
print('Invalid Proxy')
else:
print('Get IP Failed, Re Dialing')
time.sleep(ADSL_ERROR_CYCLE)
else:
print('ADSL Failed, Please Check')
time.sleep(ADSL_ERROR_CYCLE)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.