一、取得网页源文件,二、正则表达式取得包含"csdn"的url,三、取得末尾是数字的url 四、取得邮件地址
2066 2004-01-16 07:41:12 一、取得网页源文件,已经完成,代码如下:
Dim httpReq As System.Net.HttpWebRequest
Dim httpResp As System.Net.HttpWebResponse
Dim strBuff As String
Dim httpURL As New System.Uri("http://www.yourUrl.com")
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
httpReq.Method = "GET"
httpResp = CType(httpReq.GetResponse(), HttpWebResponse)
Dim reader As StreamReader = _
New StreamReader(httpResp.GetResponseStream, System.Text.Encoding.GetEncoding("GB2312"))
Dim respHTML As String = reader.ReadToEnd()
MsgBox(respHTML)
用webBrowser也可轻易取得网页源文件,但要等网页下载完毕,还有许多图片,不可取。所以用httpWebRequest
二、如何用正则表达式取得url中包含"csdn"的url。
http://expert.csdn.net/Expert/PostNew.asp
http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?可以取得url
我要用正则表达式把包含字符csdn的url提取出来,而把其他地址过滤掉,如何做
三、如何用正则表达式取得url末尾是数字的url
http://expert.csdn.net/Expert/PostNew.asp?room=5205
末尾5是数字
四、如何用正则表达式取得源文件中的邮件地址