提到数据采集,好多人的想法是用爬虫。思路没错,只是爬虫有代码和非代码之分。今天跟大家分享下如何不写一行代码,也可以轻松采集数据。
UiBot RPAUiBot是一款RPA工具,用来模拟人工操作,实现流程自动化。UiBot提供了很多指令,用来模拟和控制键盘,鼠标,人工操作。用户只需把对应的指令拖入到编辑器,UiBot会自动生成代码。
可以通过以下链接查看国内所有银行,https://www.yinhangkahao.com/bank。然后在UiBot中添加下面的指令,即可从上述网页自动采集银行数据,并保存到Excel。
自动生成的代码如下。不懂代码也没关系,完全不需要使用代码。
// 需要浏览器安装插件,或者使用内置浏览器// https://www.yinhangkahao.com/bank/Dim arrayData, sRet, objExcelWorkBook, hWeb, iRethWeb = WebBrowser.Create("uibotbrowser", "https://www.yinhangkahao.com/bank/", 10000, {"bContinueOnError": false, "iDelayAfter": 300, "iDelayBefore": 200, "sBrowserPath": "", "sStartArgs": ""})arrayData = UiElement.DataScrap({"wnd": [{"cls": "Chrome_WidgetWin_*", "title": "*", "app": "UiBot", "appargs": "resources\\browser\\app.asar"}, {"cls": "Chrome_RenderWidgetHostHWND", "title": "Chrome Legacy Window"}], "html": [{"tag": "HTML"}]}, {"ExtractTable": 0, "Columns": [{"selecors": [{"tag": "div", "index": 0, "className": "container", "value": "div.container", "prefix": ""}, {"tag": "div", "index": 2, "className": "row", "value": "div:nth-child(2)", "prefix": ">"}, {"tag": "div", "value": "div", "index": 0, "prefix": ">"}, {"tag": "a", "index": 0, "className": "list-group-item-action ", "value": "a.list-group-item-action", "prefix": ">"}, {"tag": "div", "index": 0, "className": "card", "value": "div.card", "prefix": ">"}, {"tag": "div", "index": 0, "className": "d-inline-block bankpadd", "value": "div.d-inline-block.bankpadd", "prefix": ">"}, {"tag": "h5", "index": 0, "className": "text-muted bankname", "value": "h5.text-muted.bankname", "prefix": ">"}], "props": ["text"]}]}, {"objNextLinkElement": '', "iMaxNumberOfPage": 5, "iMaxNumberOfResult": -1, "iDelayBetweenMS": 1000, "bContinueOnError": False})objExcelWorkBook = Excel.OpenExcel(@res"result.xlsx", true, "Excel", "", "")Excel.WriteRange(objExcelWorkBook, "Sheet1", "A1", arrayData, true)Excel.CloseExcel(objExcelWorkBook, true)根据上面的机器人指令,最后采集到的数据保存在Excel文件中。查看Excel中的银行名字,信息如下:
其他本篇主要讲解了通过UiBot采集数据。后续会通过其他文章介绍其他不需要使用代码的采集工具。