如何将基于网络的计算器变成可调用的程序?
我想从 C# 程序访问网页上有一个免费的在线计算器。该计算器非常简单——只是一个 HTML 表格。没有 JavaScript 或 Flash。我希望能够将此页面变成我可以调用的方法。该方法可能会调用网页,输入适当的数字,读取结果,然后返回结果。
最好的方法是什么?
There is a free, online calculator on a web page that I want to access from a C# program. The calculator is very simple -- just an HTML table. There is no JavaScript or Flash. I want to be able to turn this page into a method that I can call. The method would presumably call the web page, enter the appropriate numbers, read the result, and then return the result.
What is the best way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会尝试使用
WebBrowser
类加载网页,如果它是服务器端计算器,您应该找出 GET/POST 参数来提供输入并选择所需的功能(您可以通过分析 HTML 源代码来完成此操作) )并请求答案页。如果它是客户端计算器,您应该使用 DOM 解析器(查看HTMLDocument
类)。如果这个计算器真的很简单,我会考虑重新实现它或者尝试找到一个预先编写的组件,我认为它应该更容易(如果是客户端计算器,你可以有 javascript 源代码)。
I would try loading the web page with
WebBrowser
class, if it's a server side calculator you should figure out the GET/POST parameters to give input and choose desired functionality (you could do this by analyzing the HTML source) and request the answer page. If it is a client side calculator, you should use the DOM parser (look atHTMLDocument
class).If this calculator is really simple, I would consider re-implementing it or try to find a pre-written component, I think it should be easier (you could have the javascript source in case of client side calculator).