東拼西湊用python腳本登錄web管理頁(yè)面做巡檢(未實(shí)現(xiàn))

參考

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名申請(qǐng)、虛擬空間、營(yíng)銷軟件、網(wǎng)站建設(shè)、合作網(wǎng)站維護(hù)、網(wǎng)站推廣。

https://www.cnblogs.com/puyangsky/p/5326384.html

參考了網(wǎng)上很多博客拼出如下代碼實(shí)現(xiàn)了登錄ilom管理頁(yè)面的登錄

好像管理頁(yè)面用了js渲染無(wú)法取到想的值未能實(shí)現(xiàn)巡檢功能

#-*- coding:utf-8 -*-

import sys

from HTMLParser import HTMLParser

from bs4 import BeautifulSoup

from PyQt4.QtWebKit import *

from PyQt4.QtGui import *

from PyQt4.QtCore import *

import requests

import re

url = "https://192.40.1.8/iPages/i_login.asp"

session = requests.session()

r = session.get(url,verify = False)

content = r.content

pattern = re.compile('"loginToken", ".*"')

match = re.findall(pattern, content)

strx = "".join(match)

xsrf = re.findall(r"\s\"(.*)\"",strx)

print (xsrf)

login_data = {

? ? ? ? ? ? 'loginToken': xsrf,

? ? ? ? ? ? 'username': "oper",

? ? ? ? ? ? 'password': "Aassw0rd1"

? ? }

header1 = {? ?

? ? ? ? "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.22 Safari/537.36 SE 2.X MetaSr 1.0",

? ? ? ? "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",

? ? ? ? "Accept-Language": "zh-CN,zh;q=0.8",

? ? ? ? "Accept-Encoding": "gzip, deflate,sdch",

? ? ? ? "Content-Type": "application/x-www-form-urlencoded",

? ? ? ?# "X-Requested-With": "XMLHttpRequest",

? ? ? ? "Content-Length": "81",

? ? ? ? "Connection": "keep-alive",

? ? ? ? "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"

? ? ? ? }

baseurl = "https://192.40.1.8/iPages/loginProcessor.asp"

content = session.post(baseurl, headers = header1, data = login_data,verify=False)

content1=session.get("https://192.40.1.8/iPages/ilomtree.asp",headers = header1,verify=False)

print (content1.content)

class Render(QWebPage):

? ? def __init__(self,url):

? ? ? ? self.app = QApplication(sys.argv)

? ? ? ? QWebPage.__init__(self)

? ? ? ? self.loadFinished.connect(self._loadFinished)

? ? ? ? self.mainFrame().load(QUrl(url))

? ? ? ? self.app.exec_()

? ? def _loadFinished(self, result):

? ? ? ? self.frame = self.mainFrame()

? ? ? ? self.app.quit()

url = 'view-source:https://192.40.1.8/iPages/ilomtree.asp'

r = Render(url)

html = r.frame.toHtml()

html = html.toUtf8()

html = unicode(html,'utf8','ignore')??

print html

本文題目:東拼西湊用python腳本登錄web管理頁(yè)面做巡檢(未實(shí)現(xiàn))
URL分享:http://muchs.cn/article0/ighpoo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站軟件開發(fā)、網(wǎng)站維護(hù)、云服務(wù)器搜索引擎優(yōu)化、面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名