资源简介
获取中行汇率数据,需要的同事可以下载,保证没有问题
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.Regularexpressions;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.xml;
namespace GetWebContent
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender EventArgs e)
{
}
private void button1_Click(object sender EventArgs e)
{
tb_html.Text = GetWebContent(tb_url.Text.Trim()).Trim();
GetRate(tb_html.Text);
MessageBox.Show(“OK“ “Notice“ MessageBoxButtons.OK MessageBoxIcon.Information);
}
/// 实时汇率换算(人民币to外汇)
/// 外汇名称如:英镑、港币、美元、日元、欧元
/// 人民币价格
/// 返回实际外汇价格
//public Decimal GetRMB(string name decimal money)
//{
// if (name != “人民币“)
// {
// string wsrcString = GetWebContent(“http://www.boc.cn/cn/common/whpj.html“);//远程获取中行最新汇率
// wsrcString = wsrcString.Substring(wsrcString.IndexOf(name) wsrcString.Length - wsrcString.IndexOf(name));
// string regexStr = “yle=“\“ mce_style=“\“border-bottom: #bcbbbb 1px dashed;\“>(?.*?) “;
// Regex r = new Regex(regexStr RegexOptions.None);
// Match mc = r.Match(wsrcString);
// money = 100 / decimal.Parse(mc.Groups[“key“].Value) * money;
// return Math.Round(Convert.ToDecimal(money) 2);
// }
// else
// {
// return money;
// }
//}
/// 获取远程HTML内容
/// 远程网页地址URL
/// 成功返回远程HTML的代码内容
private string GetWebContent(string strUrl)
{
string str = ““;
try
{
WebClient wc = new WebClient();
wc.Credentials = CredentialCache.DefaultCredentials;
Encoding enc = Encoding.GetEncoding(“UTF-8“);// 如果是乱码就改成 UTF-8 / GB2312
//方法一:
//Byte[] buffer = wc.DownloadData(strUrl);// 从资源下载数据并返回字节数组
//str = enc.GetString(buffer);// 输出字符串(HTML代码)
//方法二:
Stream res = wc.OpenRead(strUrl);//以流的形式打开URL
//Stream res = new FileStream(@“E:\ExchangeRate\enindex.html“ FileMode.Open FileAccess.Read);
StreamReader sr = new StreamReader(res enc);//以指定的编码方式读取数据流
str = sr.ReadToEnd();//输出(HTML代码)
res.Close();
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 16384 2013-07-18 13:57 GetWebContent.suo
文件 13312 2013-07-18 13:57 GetWebContent\bin\Debug\GetWebContent.exe
文件 32256 2013-07-18 13:57 GetWebContent\bin\Debug\GetWebContent.pdb
文件 11592 2013-07-18 13:56 GetWebContent\bin\Debug\GetWebContent.vshost.exe
文件 490 2007-07-21 02:33 GetWebContent\bin\Debug\GetWebContent.vshost.exe.manifest
文件 134144 2012-08-06 21:30 GetWebContent\bin\Debug\HtmlAgilityPack.dll
文件 9426 2013-07-18 13:57 GetWebContent\Form1.cs
文件 8493 2013-07-16 18:45 GetWebContent\Form1.Designer.cs
文件 6014 2013-07-16 18:45 GetWebContent\Form1.resx
文件 4026 2013-07-16 16:23 GetWebContent\GetWebContent.csproj
文件 168 2011-03-23 23:08 GetWebContent\GetWebContent.csproj.user
文件 134144 2012-08-06 21:30 GetWebContent\HtmlAgilityPack.dll
文件 1487 2013-07-18 13:56 GetWebContent\obj\Debug\GetWebContent.csproj.FileListAbsolute.txt
文件 847 2013-07-16 18:45 GetWebContent\obj\Debug\GetWebContent.csproj.GenerateResource.Cache
文件 13312 2013-07-18 13:57 GetWebContent\obj\Debug\GetWebContent.exe
文件 180 2013-07-16 18:45 GetWebContent\obj\Debug\GetWebContent.Form1.resources
文件 32256 2013-07-18 13:57 GetWebContent\obj\Debug\GetWebContent.pdb
文件 180 2013-07-16 16:23 GetWebContent\obj\Debug\GetWebContent.Properties.Resources.resources
文件 3943 2013-07-16 16:23 GetWebContent\obj\Debug\ResolveAssemblyReference.cache
文件 494 2011-03-23 21:55 GetWebContent\Program.cs
文件 1376 2011-03-23 21:55 GetWebContent\Properties\AssemblyInfo.cs
文件 2876 2011-03-23 21:55 GetWebContent\Properties\Resources.Designer.cs
文件 5612 2011-03-23 21:55 GetWebContent\Properties\Resources.resx
文件 1098 2011-03-23 21:55 GetWebContent\Properties\Settings.Designer.cs
文件 249 2011-03-23 21:55 GetWebContent\Properties\Settings.settings
文件 929 2013-07-18 13:57 GetWebContent.sln
目录 0 2011-03-23 22:28 GetWebContent\obj\Debug\Refactor
目录 0 2011-03-23 21:55 GetWebContent\obj\Debug\TempPE
目录 0 2013-07-16 16:23 GetWebContent\bin\Debug
目录 0 2013-07-18 13:57 GetWebContent\obj\Debug
............此处省略7个文件信息
相关资源
- C# 调用win32 api函数-user32.dll详细说明
- C# 调用BarTender打印条码DEMO
- ASP.NET程序开发范例宝典 百度云
- asp.net FileUpload 上传进度条
- 大型比赛竞赛抽签系统 可打印 c# vs
- 很好用的一个asp.net反编译软件
- C#编写的Gerber查看器
- lua C# .Net4.0 vs2010 LuaInterface
- asp.net实现qq登陆
- C#十六进制编辑器
- 明华URF-35H读卡器 C#读写源码 为大家
- C#文件流读取CSV文件
- c#读写PDF文件sql
- C# winform Socket大文件传输
- c#车牌识别系统附30张测试图片
- 《C#面向对象程序设计》源代码(CS)
- 金旭亮《C#面向对象程序设计》教案
- 试题库管理系统毕业论文(C#)源程序
- 学校网站原代码(C#.NET)
- C#-数据库操作技术-员工管理系统
- c#web开发入门经典
- C#与Matlab混合编程的几种方式
- c# 开发与 mysql数据库实现的增删改查
- C#异步操作 异步查询数据库 异步处理
- Basler相机通过IO触发源码
- 亮剑asp.net案例导航项目开发
- 亮剑ASP.NET项目开发案例导航-part03共三
- [源代码] 《领域驱动设计 (C# 2008 实
- 松下PLC与C#通讯串口调试入门教程.z
- USB 继电器控制器 LCUS-1 保证能用 c#
评论
共有 条评论