我需要一个脚本,使它像一个cpanel检查器,有一个以上的网址和网址是存储在一个txt文件
用法:python script.py list.txt
文件list.txt中的格式:https://demo.cpanel.net:2083|democom|DemoCoA5620
这是我的代码,但不起作用,有人能帮我吗
谢谢
import requests, sys
from multiprocessing.dummy import Pool as ThreadPool
try:
with open(sys.argv[1], 'r') as f:
list_data = [line.strip() for line in f if line.strip()]
except IOError:
pass
def cpanel(url):
try:
data = {'user':'democom', 'pass':'DemoCoA5620'}
r = requests.post(url, data=data)
if r.status_code==200:
print "login success"
else:
print "login failed"
except:
pass
def chekers(url):
try:
cpanel(url)
except:
pass
def Main():
try:
start = timer()
pp = ThreadPool(25)
pr = pp.map(chekers, list_data)
print('Time: ' + str(timer() - start) + ' seconds')
except:
pass
if __name__ == '__main__':
Main()
我修复了您的代码,它将返回一个实际数组,其中包含一个表示cpanel函数成功的布尔数组
输出:
请注意,我用一些固定的URL替换了您的文件读取操作
既然您使用了
request.post
,我猜您实际上是想发布一些东西到那个url。你的代码不能这样做。如果您只想发送请求,请使用requests.get
方法有关更多详细信息,请参阅请求包的官方文档:
https://2.python-requests.org/en/master/user/quickstart/#make-a-request
还要注意的是
这不是问题
相关问题 更多 >
编程相关推荐