python脚本实现模拟登录、批量请求

python脚本实现模拟登录

import requests
"""
http://182.92.130.63:8088/login
"""
url = "http://182.92.130.63:8088/login?action=login"
user = "admin"
passwd = "admin"
type = "A"
headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Connection': 'keep-alive',
}
login_data = {
    'user_id': user,
    'pwd': passwd,
    'tm_type':type
}
s = requests.post(url,data=login_data,headers=headers)
print(s)
print(s.status_code)

python脚本实现存活网站探测,即进行批量的网站请求

第一步

先将需要探测的网站全部写入文件:baidu.com子域名列表_Layer.txt

第二步

import requests

with open("baidu.com子域名列表_Layer.txt", "r") as ff:
    a = ff.readlines()
print(a)
cleaned_list = [item.replace("\n", "") for item in a]
print(len(cleaned_list))
print(cleaned_list)
http = []
https = []
u = 0
for i in range(len(cleaned_list)):
    try:
        ull = cleaned_list[i]
        g = requests.get(f"http://{ull}", timeout=2)
        if g.status_code == 200:
            http.append(f"http://{ull}")
            u += 1
    except:
        print('xx')

for i in range(len(cleaned_list)):
    try:
        ull = cleaned_list[i]
        g = requests.get(f"https://{ull}", timeout=2)
        if g.status_code == 200:
            https.append(f"https://{ull}")
            u += 1
    except:
        print('xx')

with open("xhttp.txt", "w") as ss:
    for i in range(len(http)):
        ss.write(f"{http[i]}\n")

with open("xhttps.txt", "w") as ss:
    for i in range(len(https)):
        ss.write(f"{https[i]}\n")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值