uibot案例

通过uibot去下载uibot官网的学习视频

// 启动浏览器打开网页
hWeb = WebBrowser.Create("chrome","https://forum.uibot.com.cn/thread-50.htm",30000,{
     "bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200,"sBrowserPath":"","sStartArgs":""})
// 等待加载完成
iRet = WebBrowser.WaitPage(hWeb,"",60000,{
     "bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
// 抓取页面中的url
arrayData = UiElement.DataScrap({
     "html":[{
     "tag":"MAIN"}],"wnd":[{
     "app":"chrome","cls":"Chrome_WidgetWin_1","title":"*"},{
     "cls":"Chrome_RenderWidgetHostHWND","title":"Chrome Legacy Window"}]},{
     "Columns":[{
     "props":["text","url"],"selecors":[{
     "className":"container","index":0,"prefix":"","tag":"div","value":"div.container"},{
     "className":"row","index":0,"prefix":">","tag":"div","value":"div.row"},{
     "className":"col-lg-9 main","index":0,"prefix":">","tag":"div","value":"div.col-lg-9.main"},{
     "className":"card card-thread","index":0,"prefix":">","tag":"div","value":"div.card.card-thread"},{
     "className":"card-body","index":0,"prefix":">","tag":"div","value":"div.card-body"},{
     "className":"message break-all","index":0,"prefix":">","tag":"div","value":"div.message.break-all"},{
     "index":0,"prefix":">","tag":"p","value":"p"},{
     "index":0,"prefix":">","tag":"span","value":"span"},{
     "index":0,"prefix":">","tag":"span","value":"span"},{
     "className":"","index":0,"prefix":">","tag":"a","value":"a"}]}],"ExtractTable":0},{
     "objNextLinkElement":"","iMaxNumberOfPage":1,"iMaxNumberOfResult":-1,"iDelayBetweenMS":1000,"bContinueOnError":false})
// 遍历url
For Each arr In arrayData
    TracePrint(arr[0])
    // 打开某个url
    iRet = WebBrowser.GoURL(hWeb,arr[0],true,"",30000,{
     "bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
    #icon("@res:p7g83tgj-2dag-kfqn-0s8o-csde8vh6p2b2.png")
    bRet = UiElement.Exists({
     "wnd":[{
     "cls":"Chrome_WidgetWin_1","title":"*","app":"chrome"},{
     "cls":"Chrome_RenderWidgetHostHWND","title":"Chrome Legacy Window"}],"html":[{
     "tag":"VIDEO"}]},{
     "bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
    TracePrint(bRet)
    If bRet
        // 获取src属性的值,获取链接
        #icon("@res:s1uq6mdk-duts-ovr2-ffod-soo8rol3faq1.png")
        sRet = UiElement.GetAttribute({
     "wnd":[{
     "cls":"Chrome_WidgetWin_1","title":"*","app":"chrome"},{
     "cls":"Chrome_RenderWidgetHostHWND","title":"Chrome Legacy Window"}],"html":[{
     "tag":"VIDEO"}]},"src",{
     "bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
        // 通过链接下载视频文件
        arrRet = Split(sRet,"/")
        TracePrint(arrRet[Len(arrRet)-1])
        dTime = Time.Format(Time.Timer(),"yyyymmddhhmmss")
        sText = HTTP.GetFile(sRet, "C:\\Users\\Administrator\\Desktop\\123\\"&dTime&".mp4", {
     }, 60000)
        TracePrint(sText)
        
Else
        Continue
End If

Next

你可能感兴趣的:(uibot)