PHP笔记网

革命尚未成功,同志仍须努力下载JDK17

作者:Albert.Wen  添加时间:2023-06-17 23:46:32  修改时间:2024-11-27 03:51:23  分类:03.数据采集/爬虫  编辑

1、绑定、创建 浏览器对象

//++++++++++++++++++++++++++++++++++++++++++++
// 1.打开浏览器
//++++++++++++++++++++++++++++++++++++++++++++

// 浏览器类型: 360se  edge  chrome
g_浏览器_类型 = "edge"
g_浏览器_对象 = WebBrowser.BindBrowser(g_浏览器_类型,30000,{"bContinueOnError":true,"iDelayAfter":0,"iDelayBefore":0})
If IsNull(g_浏览器_对象) 
    g_浏览器_对象=WebBrowser.Create(g_浏览器_类型,"about:blank",30000,{"bContinueOnError":true,"iDelayAfter":0,"iDelayBefore":0,"sStartArgs":""})
End If
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

If isNull(g_浏览器_对象)
    // 浏览器类型: 360se  edge  chrome
    g_浏览器_类型 = "edge"
    g_浏览器_对象 = WebBrowser.BindBrowser(g_浏览器_类型,30000,{"bContinueOnError":true,"iDelayAfter":0,"iDelayBefore":0})
    If IsNull(g_浏览器_对象): 
        g_浏览器_对象=WebBrowser.Create(g_浏览器_类型,"about:blank",30000,{"bContinueOnError":true,"iDelayAfter":0,"iDelayBefore":0,"sStartArgs":""})
    End If

    // 跳转至“刷价”页面
    // WebBrowser.GoURL(g_浏览器_对象,"https://www.maersk.com.cn/instantPrice/",true,{},20000,{"bContinueOnError":true,"iDelayAfter":0,"iDelayBefore":0})

End If

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

2、当前页面URL

Dim cur_page_url = WebBrowser.GetURL(g_浏览器_对象,{"bContinueOnError":true,"iDelayAfter":0,"iDelayBefore":0})
TracePrint("当前页面地址:" & cur_page_url)
If api.is_page_url(cur_page_url, "https://www.maersk.com.cn/instantPrice/") 
    // 点击“搜索”按钮
    Mouse.Action(@ui"edge_查询_搜索_按钮","left","click",10000,{"bContinueOnError": true, "iDelayAfter": 0, "iDelayBefore": 0, "bSetForeground": true, "sCursorPosition": "Center", "iCursorOffsetX": 0, "iCursorOffsetY": 0, "sKeyModifiers": [],"sSimulate": "simulate", "bMoveSmoothly": true})
End If