import requests,traceback,sys,time
space=" "*20+"\b"*20
def getProxies():
print("正在获取代理")
r=requests.get("https://ip.jiangxianli.com/api/proxy_ips?order_by=speed").json()
if not r["code"]:
for i in r["data"]["data"]:
yield f'{i["protocol"]}://{i["ip"]}:{i["port"]}'
time.sleep(1)
for j in range(2,r["data"]["total"]+1):
r=requests.get(f"https://ip.jiangxianli.com/api/proxy_ips?order_by=speed,page={j}").json()
if not r["code"]:
for i in r["data"]["data"]:
yield f'{i["protocol"]}://{i["ip"]}:{i["port"]}'
time.sleep(1)
print("代理获取完成")
for i in getProxies():
#print(i)
#sys.stdout.write(f"\r{i}{space}")
#sys.stdout.flush()
try:
if requests.get("http://api.bilibili.com/x/web-interface/zone",proxies={"http":i,"https":i},timeout=5).text in i:
print(i)
except KeyboardInterrupt: break
except:pass#traceback.print_exc()
#sys.stdout.write(space)