uibot小作业:检测并输出在科创板审核网站无法搜索到有关公司的证券简称

2021/12/19 23:49:59

本文主要是介绍uibot小作业:检测并输出在科创板审核网站无法搜索到有关公司的证券简称,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

目录

    • 知识点
    • 代码块

知识点

1、txt文件读取,分行遍历
2、浏览器调用
3、JS调用:获取对象及其文本
Tips:console测试JS;源代码中不含动态元素;

代码块

function(){
x=document.getElementById("zeroRecordDiv_stock_list")
if (x!=null)
{return x.textContent}
else
{return null}
}
//sRet = File.Read('''C:\Users\huang\Desktop\搜索关键字.txt''',"utf-8")
Dim sRet
Function file_readline(path,sCharset='utf-8')
    Try
        Dim sText= File.Read(path,sCharset)
        dim arrText = Split(sText,"\n")
    Catch err
            TracePrint("错误流程块:" & err["File"] &\
            ",错误信息:" & err["Line"] &\
            ",错误信息:" & err["Message"])
    Else
        Return arrText
        //数组下标从0开始
    End Try
End Function
dim input="C:\\Users\\huang\\Desktop\\搜索关键字.txt"
dim words=file_readline(input)
//Dim nLines  = UBound(words)+1
dim url="http://kcb.sse.com.cn/renewal/index.shtml?"
//dim url0="http://kcb.sse.com.cn/renewal/index.shtml?key=方邦股股份"
dim urls=[]
dim hWeb = WebBrowser.Create("uibotbrowser",url,3000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200,"sBrowserPath":"","sStartArgs":""})
For i = 0 To Len(words)-1 step 1
    urls[i]=url&"key="&words[i]
    dim iRet
    iRet= WebBrowser.GoURL(hWeb,urls[i],true,{},30000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
    sRet = WebBrowser.GetURL(hWeb,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
    dim Ret
    Ret = WebBrowser.RunJS(hWeb,"function(){\nx=document.getElementById(\"zeroRecordDiv_stock_list\")\nif (x!=null)\n{return x.textContent}\nelse\n{return null}\n}",true,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
    If InStr(Ret,"暂无数据",1,false)<>0

        Traceprint(words[i],Ret) 
    else    
        Traceprint(InStr(Ret,"暂无数据",1,false)) 
    End If
Next



这篇关于uibot小作业:检测并输出在科创板审核网站无法搜索到有关公司的证券简称的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程