1

我正在尝试从网站自动提取数据,但我真的不知道从哪里开始。我们的一个供应商允许我们通过“ Business Objects 11 ”访问一些设备记录数据。” 在线应用程序。如果您不熟悉此在线应用程序,请将其视为基于 Web 的报告生成器。问题是我正在尝试监控很多设备,而该供应商仅创建了一个提取一个日志的请求一次。这个请求需要设备号,开始日期和结束日期......更糟糕的是,我们只能导出为二进制 Excel 格式,因为 de "csv" 导出已损坏并且他们拒绝修复它.. . 因此我们受到 Excel 的 65 536 行限制...(在我的情况下相当于 3-4 天的数据记录)。我无法创建新的请求,因为只有供应商拥有必要的管理员权限。

您认为通过 Web GUI 运行大量请求(大约 800 个)的最优雅方式是什么?我想我可以硬编码鼠标位置、点击事件和按键延迟等等……但必须有更好的方法。

我阅读了有关 AutoHotKey 和 AutoIt 脚本的信息,但它们似乎受限于它们可以在网络上执行的操作。另外...我被IE6卡住了...但是如果您知道涉及另一个浏览器的方法,我仍然对您的回答非常感兴趣。

(一旦我在本地拥有日志文件,提取数据就不是问题了)

4

3 回答 3

1

There are some things you might try. If the site is a html and reports can be requested by a simple POST or GET then urlib/urlib2 and cookielib Python modules should be enough to fetch an excel document.

Then you can try this: xlrd to extract data from excel.

Also, take a look at: http://pamie.sourceforge.net/. I never tried it myself but looks promising and easy to use.

于 2009-07-08T15:52:40.270 回答
0

由于您可以使用 .NET,因此您应该考虑使用 Windows 窗体 WebBrowser 控件。您可以自动导航到站点、按下按钮等。加载报告页面后,您可以使用代码导航 HTML DOM 以查找所需的数据 - 不涉及正则表达式。

几年前我做过类似的事情,从 eBay 提取拍卖数据。

于 2010-02-19T05:25:30.910 回答
0

Normally, I would suggest not to use IE (or any browser) at all. Remember, web browser software are just proxy programs for making http requests and displaying the results in meaningful ways. There are other ways you can make similar http requests and process the responses. Almost every modern language has this built into it's API somewhere. This is called screen scraping or web scraping.

But to complete this suggestion I need to know more about your programming environment: ie, in what programming language do you envision writing this script?

A typical example using C# where you just get the html result as string would look like this:

new System.Net.WebClient().DownloadString("http://example.com");

You then parse the string to find any fields you need and send another request. The WebClient class also have a .DownloadFile() method that you might find useful for retrieving the excel files.

于 2009-07-08T15:51:46.013 回答