using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;
namespace WindowsFormsApplication2{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.abc.com/news.aspx?class=111111&cid=22222222");
}
private void button1_Click(object sender, EventArgs e)
{
string url = webBrowser1.Url.Query.ToString(); //獲取地址的參數
url = url.Replace("?", ""); //去除第一個參數的問號
string[] urlParam = url.Split('&'); //根據參數間的& 號獲取參數數組
foreach (string s in urlParam)
{
string[] val = s.Split('='); //將參數名與參數值賦值給數組
MessageBox.Show("參數名稱為:" + val[0] + " 參數值為:" + val[1]);
}
}
}}
沒有留言:
張貼留言