zoukankan      html  css  js  c++  java
  • python通过token登录,并爬取数据实例

     1 from bs4 import BeautifulSoup
     2 import requests
     3 
     4 class Zabbix(object):
     5     def __init__(self, headers):
     6         self.session = requests.Session()
     7         self.headers = headers
     8     def func(self):
     9         headers={
    10             'Host':'172.28.14.165',
    11             'Upgrade-Insecure-Requests':'1',
    12             'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36',
    13             'cookie':'zbx_sessionid='+token
    14         }
    15         response=self.session.get(url='http://172.28.14.165/zabbix/zabbix.php?action=report.status&ddreset=1',headers=headers,allow_redirects=False)
    16         sourse = BeautifulSoup(response.text, 'html.parser')
    17         text=sourse.find('span', {'class': 'green'})
    18         if not text :
    19             text=sourse.find('span', {'class': 'red'})
    20         tq=text.string
    21         print(tq)
    22 if __name__ == '__main__':
    23     headers = {
    24         'Host': '172.28.14.165',
    25         'Origin': 'http://172.28.14.165',
    26         'Referer':'http://172.28.14.165/zabbix/index.php',
    27         'Upgrade-Insecure-Requests':'1',
    28         'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36',
    29     }
    30     status = Zabbix(headers=headers)
    31     token=input("please input token:")
    32     status.func()
    View Code
  • 相关阅读:
    Weblogic 漏洞利用总结
    CVE-2017-9993 FFMpeg漏洞利用
    tomcat漏洞利用总结
    移动渗透测试杂记
    CORS漏洞利用检测和利用方式
    discuz mlv3.x命令注入
    DNS域传输漏洞利用总结
    redis未授权漏洞和主从复制rce漏洞利用
    CVE-2016-3714-ImageMagick 漏洞利用
    JAVA WEB EL表达式注入
  • 原文地址:https://www.cnblogs.com/navysummer/p/8856115.html
Copyright © 2011-2022 走看看