当前位置:首页 > DayDayUp > 正文内容

大华优橙平台自动填写脚本(纯selenium/selenium+requests)

Luz2个月前 (10-16)DayDayUp198
from selenium import webdriver
import time
import re
import requests
import json
from selenium.webdriver.common.keys import Keys
w1 = 'PasswordInput_'
w2 = '\"'
urls=[]
noo=10041
browser = webdriver.Chrome()
for uuuu in urls:

    #url="http://39.172.60.230:1080/"
    username="admin"
    passwd="admin123"
    server="http://zhtc.ajjczh.com/openapi/v2/highvideo"
    timee="300"
    browser.get(uuuu)
    browser.implicitly_wait(10)
    elem=browser.find_element_by_class_name("ant-input")
    elem.send_keys(username)
    time.sleep(1)
    #print(browser.page_source)
    pat = re.compile(w1+'(.*?)'+w2,re.S)
    result = pat.findall(browser.page_source)
    #print(result)
    id=w1+result[0]
    print(id)
    elem=browser.find_element_by_id(w1+result[0])
    elem.send_keys(passwd)
    time.sleep(1)
    elem=browser.find_element_by_xpath("//*[@id=\"root\"]/div/div/div/div/form/div[3]/div/div/span/button")
    elem.click()
    time.sleep(10)
    cookiess=browser.get_cookies()
    session=''
    for i in cookiess:
        if i['name']=='WebClientSessionID':
            print(i['value'])
            session=i['value']
            
    pa={
        "method":"system.multicall",
        "params":[
            {
                "method":"configManager.setConfig",
                "params":{
                    "name":"VSP_YCPT_BASIC",
                    "table":{
                        "DataSplit":'0',
                        "DebugLevel":'4',
                        "DeviceId":str(noo),
                        "GatherMode":'0',
                        "JsonHandle":'0',
                        "ListenPort":'8002',
                        "PictureMode":'0',
                        "PictureOrder":'0',
                        "ProtocolVersion":'0',
                        "RecvTimeout":'5000',
                        "SendTimeout":'5000',
                        "ServerInfo":[
                            {
                                "Url":"http://zhtc.ajjczh.com/openapi/v2/highvideo"
                            },
                            {
                                "Url":"http://zhtc.ajjczh.com/openapi/v2/highvideo"
                            },
                            {
                                "Url":"http://zhtc.ajjczh.com/openapi/v2/highvideo"
                            },
                            {
                                "Url":"http://zhtc.ajjczh.com/openapi/v2/highvideo"
                            },
                            {
                                "Url":"http://zhtc.ajjczh.com/openapi/v2/highvideo"
                            },
                            {
                                "Url":"http://zhtc.ajjczh.com/openapi/v2/highvideo"
                            },
                            {
                                "Url":"http://zhtc.ajjczh.com/openapi/v2/highvideo"
                            }
                        ],
                        "TimeSliceEnable":'0',
                        "Version":'20191203'
                    },
                    "options":[

                    ]
                },
                "id":'219',
                "session":session
            },
            {
                "method":"configManager.setConfig",
                "params":{
                    "name":"VSP_YCPT_MODULE",
                    "table":{
                        "Enable":'false',
                        "HeartbeatCycle":'10000',
                        "Link":[
                            {
                                "Group":""
                            }
                        ],
                        "SubModuleEnable":{
                            "DeviceManagerEnable":'false',
                            "EventEnable":'true',
                            "HeartbeatEnable":'false',
                            "PictureEnable":'true',
                            "RegisterEnable":'false'
                        }
                    },
                    "options":[

                    ]
                },
                "id":'220',
                "session":session
            },
            {
                "method":"configManager.setConfig",
                "params":{
                    "name":"VSP_YCPT_PICTURE",
                    "table":[
                        {
                            "Code":"TrafficJunction:0",
                            "FTPServer":[
                                {
                                    "Enable":'true'
                                },
                                {
                                    "Enable":'true'
                                },
                                {
                                    "Enable":'true'
                                },
                                {
                                    "Enable":'true'
                                }
                            ],
                            "Filter":"",
                            "Group":"Whole&Dig",
                            "ManualOffTime":{
                                "Enable":'false',
                                "EndTime":"2000-01-01 00:00:00",
                                "StartTime":"2000-01-01 00:00:00"
                            },
                            "Mode":{
                                "CharacterEncode":'1',
                                "Replacement":"",
                                "UploadMode":'0'
                            },
                            "OfflineTransferAddrIndex":'0'
                        },
                        {
                            "Code":"TrafficRunRedLight:4|TrafficOverLine:23|TrafficOverYellowLine:88|TrafficRetrograde:42|TrafficU-Turn:78|TrafficCrossLane:5|TrafficParking:99|TrafficOverSpeed:1|TrafficWrongRoute:23|TrafficStay:31|TrafficPedestrainPriority:3|TrafficVehicleInRoute:25|TrafficVehicleInBusRoute:25|TrafficOverStopLine:79|TrafficParkingOnYellowBox:27|TrafficWithoutSafeBelt:97|TrafficDriverCalling:98|TrafficBigBendSmallTurn:92|TrafficQueueJump:75|TrafficJamForbidInto:31|TrafficTurnLeftAfterStraight:89|TrafficTurnRightAfterPeople:89|TrafficTurnRightAfterStraight:89|TrafficNoPassing:11|TrafficTurnLeft:11|TrafficTurnRight:11|TrafficYellowInRoute:11|TrafficRestrictedPlate:11",
                            "FTPServer":[
                                {
                                    "Enable":'true'
                                },
                                {
                                    "Enable":'true'
                                },
                                {
                                    "Enable":'true'
                                },
                                {
                                    "Enable":'true'
                                }
                            ],
                            "Filter":"",
                            "Group":"Whole&Dig",
                            "ManualOffTime":{
                                "Enable":'false',
                                "EndTime":"2000-01-01 00:00:00",
                                "StartTime":"2000-01-01 00:00:00"
                            },
                            "Mode":{
                                "CharacterEncode":'1',
                                "Replacement":"",
                                "UploadMode":'0'
                            },
                            "OfflineTransferAddrIndex":'1'
                        }
                    ],
                    "options":[

                    ]
                },
                "id":'221',
                "session":session
            },
            {
                "method":"configManager.setConfig",
                "params":{
                    "name":"VSP_YCPT_CHANNEL",
                    "table":[
                        {
                            "ChannelId":"",
                            "DataSource":"",
                            "Enable":'false',
                            "Illegal":{
                                "Address":"",
                                "CollectOrgan":"",
                                "Id":"",
                                "PlaceId":""
                            },
                            "TrafficGate":{
                                "Id":"",
                                "PlaceId":""
                            }
                        }
                    ],
                    "options":[

                    ]
                },
                "id":'222',
                "session":session
            },
            {
                "method":"configManager.setConfig",
                "params":{
                    "name":"VSP_YCPT_EVENT",
                    "table":{
                        "Group":""
                    },
                    "options":[

                    ]
                },
                "id":'223',
                "session":session
            },
            {
                "method":"configManager.setConfig",
                "params":{
                    "name":"VSP_YCPT_CUSTOM",
                    "table":{
                        "Custom":{
                            "DifferentPicHandleEnable":'false',
                            "GatherQueNum":10,
                            "GatherTimeOut":5000,
                            "HandleMode":0,
                            "NoCompleteGroupAckTime":300,
                            "NoCompleteGroupPolicy":"Upload",
                            "Picture":[
                                {
                                    "Code":"",
                                    "Group":""
                                }
                            ],
                            "VideoQueryTimeOut":15
                        },
                        "ParkingNo":str(noo),
                        "StateReportCycle":300
                    },
                    "options":[

                    ]
                },
                "id":224,
                "session":session
            }
        ],
        "id":225,
        "session":session
    }
    headerss={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0',
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
'Content-Type':'application/json',
'Cookie': 'secure; WebClientSessionID='+session+'; username=admin'
}
    #urlllll=uuuu+"/RPC2"
    #print(urlllll)
    #print(requests.post(url=urlllll,headers=headerss,data=json.dumps(pa)).text)

    elem=browser.find_element_by_xpath("//*[@id=\"public-head\"]/div[2]/span[1]/div[2]")
    elem.click()
    time.sleep(3)
    elem=browser.find_element_by_xpath("//*[@id=\"postionDiv\"]/div/div/div/ul/li[3]")
    elem.click()
    time.sleep(3)
    elem=browser.find_element_by_xpath("//*[@id=\"YCPT\"]")
    elem.click()
    time.sleep(5)
    browser.save_screenshot(str(noo)+'.png')
    noo=noo+1
    """
    #browser.execute_script("document.getElementByXpath(\"//*[@id=\"main\"]/div/div[2]/div/div/div[2]/div[2]/div/div[1]/div/div[2]/input\").value="+server)
    elem=browser.find_element_by_xpath("//*[@id=\"main\"]/div/div[2]/div/div/div[2]/div[2]/div/div[1]/div/div[2]/input")
    elem.clear()
    elem.send_keys(server)
    time.sleep(1)
    elem=browser.find_element_by_xpath("//*[@id=\"main\"]/div/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div[2]/input")
    elem.clear()
    elem.send_keys(noo)
    elem=browser.find_element_by_xpath("//*[@id=\"main\"]/div/div[2]/div/div/div[2]/div[2]/div/div[3]/div/div[2]/input")
    elem.clear()
    elem.send_keys(noo)
    #browser.execute_script("document.getElementByXpath(\"//*[@id=\"main\"]/div/div[2]/div/div/div[2]/div[2]/div/div[4]/div/div[2]/div/div[2]/input\").value="+timee)
    elem=browser.find_element_by_xpath("//*[@id=\"main\"]/div/div[2]/div/div/div[2]/div[2]/div/div[4]/div/div[2]/div/div[2]/input")
    elem.send_keys(Keys.BACKSPACE)
    elem.send_keys(Keys.BACKSPACE)
    elem.send_keys(Keys.BACKSPACE)
    elem.send_keys(Keys.BACKSPACE)
    elem.send_keys(Keys.BACKSPACE)
    elem.send_keys(Keys.BACKSPACE)
    elem.send_keys(timee)
    elem=browser.find_element_by_xpath("//*[@id=\"main\"]/div/div[2]/div/div/div[4]/div[2]/div/div/label/span[1]/input")
    elem.click()
    time.sleep(1)
    elem=browser.find_element_by_xpath("//*[@id=\"main\"]/div/div[2]/div/div/div[1]/div/label/span[1]/input")
    elem.click()
    time.sleep(3)
    elem=browser.find_element_by_xpath("//*[@id=\"main\"]/div/div[2]/div/div/div[5]/div/button[1]")
    elem.click()
    time.sleep(10)
    noo=noo+1"""

image.png

分享给朋友:

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。