web| Data | web | The title of this is very simple, the Bank of China has a page to check the exchange rate of the day (http://www.bank-of-china.com/info/qpindex.shtml), but the traditional HTML format, It does not provide XML format or WebService queries. Now if you want other information systems to be able to read the data at any time, it is more convenient than the bank to provide a WebService interface for everyone to call, which is also a typical security WebService application. Unfortunately, the bank did not do so, can we do it ourselves? Of course, as long as the application analysis of its HTML page, then it is easy to read the data. Text analysis, of course, to see our "Regular Expression" (hehe, in fact, this is the real purpose of writing this program-the application of regular expressions. )
The page of the bank is similar to the following:
Date: 2004/09/30 valid until 2004/10/07
Currency name cash purchase rate rate base price
GBP 1488.1700
1453.1500
1492.6400
HK $105.9700
105.3300
106.2900
106.1100
USD 826.4200
821.4500
828.9000
827.6600
Swiss Franc 655.9300
641.1400
659.2200
Singapore Dollar 488.7600
477.2600
490.2300
Swedish krona 112.4900
109.8400
112.8300
Danish krone 136.5900
133.3700
137.0000
Norwegian krone 121.9500
119.0800
122.3100
Japanese Yen 7.4344
7.3785
7.4717
7.4519
Canadian Dollar 650.8000
635.4800
652.7600
Australian dollar 591.9900
578.6400
594.9600
EUR 1019.6400
1010.9600
1022.7000
1019.7000
Macau Dollar 103.2200
102.6000
103.5300
Philippine Peso 14.6700
14.3300
14.7200
Thai Baht 19.9000
19.4300
19.9600
New Zealand dollar 553.7000
555.3600
After the analysis of its code, given a regular expression, of course, this expression is not perfect, but for the current relatively fixed rate page of the BOC, there is no problem for the time being.
Then the filter is very simple. I always thought the code was the best description, especially for the elegant language, because I didn't say much, and the code waited.
This is the code for the WebService page Foreignexchange.asmx:
Using System;
Using System.Collections;
Using System.ComponentModel;
Using System.Data;
Using System.Diagnostics;
Using System.Web;
Using System.Net;
Using System.Web.Services;
Using System.Xml;
Using System.Text;
Using System.Text.RegularExpressions;
Using System.IO;
Namespace Chinabank
{
<summary>
Summary description for Foreignexchange.
</summary>
[WebService (namespace= "http://dancefires.com/ChinaBank/")]
public class ForeignExchange:System.Web.Services.WebService
{
Public Foreignexchange ()
{
Codegen:this call are required by the ASP.net Web Services Designer
InitializeComponent ();
}
#region Component Designer generated code
Required by the Web Services Designer
Private IContainer components = null;
<summary>
Required to Designer support-do not modify
The contents is with the Code Editor.
</summary>
private void InitializeComponent ()
{
}
<summary>
Clean up any being used.
</summary>
protected override void Dispose (bool disposing)
{
if (disposing && components!= null)
{
Components. Dispose ();
}
Base. Dispose (disposing);
}
It is also easy for the client to call directly when the corresponding WebService proxy is generated with WSDL, because I have the server side return the dataset, so the client directly displays the DataSet with a DataGrid The client has no technical key points on this issue.
Using System;
Using System.Threading;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.