hai
friends&&gentlemens
I am developing an windows application.the application deals with extracting urls from a specified webpage(web page name will be given dynamically).now i want to get all the urls/phone nos/fax no presented in that web page.friends give me ur valuable suggestions
thnks to everybody
sravanthi nagineniPosted Jul 21, 2006, 2:48 AM
request =
CType(WebRequest.Create(sURL), HttpWebRequest) ' get the responseresponse =
CType(request.GetResponse(), HttpWebResponse) ' get the stream of data and read into a strings = response.GetResponseStream()
strContents =
New StreamReader(s).ReadToEnd() Catch ex As Exception Return ex.Message End Try Return strContents End FunctionDim rRegEx As Regex Dim mMatch As Match Dim tMatch As Match Dim aMatch As New ArrayList
rRegEx =
New Regex("^""\+[0-9]{1,3}\([0-9]{3}\)[0-9]{7}""$")mMatch = rRegEx.Match(sHTMLContent)
Try While mMatch.SuccessaMatch.Add(mMatch)
mMatch = mMatch.NextMatch()
End While Catch ex As ExceptionMsgBox(ex.Message)
End Try Return aMatch End Functionin this application very poor if we are run the application
s = response.GetResponseStream()
strContents = New StreamReader(s).ReadToEnd()
here hang the application
what iam doing
how to extract the particuler fax no ,phone no plz give me valueble suggestion in vb.net
sravanthi nagineniPosted Jul 18, 2006, 4:06 AM
mallikarjuna prasad thanka for replying , i have analyzed so many concepts recarding regular expressions ,this is very difficult ,could ple explain clearly my project information,
my mail id is [email protected]
mallikarjun prasadPosted Jul 18, 2006, 1:23 AM
Earlier in my previous company we done this kind of problems. There we need to get the all the information from the webpages. At that times we are using Instr function for caputing the values at different parts of the webpages. The Prime requirement to that is we need to search the unique object(means any images, id, text what ever it may be it should unique before your requirement) then add some values to it and get close to your phone, fax etc. Then u can extract the your requirement from them. A sample of extraction is giving below. Till u have not understood give me your personal mail address i will send the project in doc format. ok bye
t1 = InStr(1, Tmp, "
If t1 > 0 Then Tmp = Mid(Tmp, t1 - 1)
t1 = InStr(1, Tmp, "", vbTextCompare)
If t1 > 0 Then Tmp = Mid(Tmp, 1, t1 - 1)
t1 = InStr(1, Tmp, "", vbTextCompare)
If t1 > 0 Then Tmp = Mid(Tmp, t1 + 7)
'Strip out everything in
Do
t1 = InStr(1, Tmp, "
If t1 = 0 Then Exit Do
t2 = InStr(t1 + 1, Tmp, "", vbTextCompare)
If t2 = 0 Then Exit Do
Tmp = Mid(Tmp, 1, t1 - 1) & " " & Mid(Tmp, t2 + 9)
Loop
'Strip out comments
AdamPosted Jul 17, 2006, 11:07 AM
sravanthi nagineniPosted Jul 17, 2006, 8:27 AM
mallikarjuna idonth'v knowlegde about regx ,so iam asking more times ,now iam found how to extract the urls,and metatags ,could u ple explain how to extact the phone no,faxes,emails from webpages ,just give me ur valuble suggestion thts enough
thanku for evry one ,thanku somuch
mallikarjun prasadPosted Jul 13, 2006, 3:04 AM
For that u need to write an application .
In the below function will take url as input and give the total webpage content as output.
after that u need to find a unique search for capturing what u need.
Public Function user_webrequest_current(ByVal URL1 As String) As String
Try
Dim request1 As WebRequest = WebRequest.Create(URL1)
Dim response1 As WebResponse = request1.GetResponse()
Dim reader1 As StreamReader = New StreamReader(response1.GetResponseStream())
Dim gethtmlcode1 As String
gethtmlcode1 = reader1.ReadToEnd
user_webrequest_current = gethtmlcode1
Catch e As Exception
user_webrequest_current = ""
MsgBox(e.Message, MsgBoxStyle.OKOnly, "current News")
Application.Exit()
End Try
End Function
Dipen LamaPosted Jul 13, 2006, 12:52 AM
See WebRequest and WebResponce class for this.
Here is a sample code to retreive the page content from window form.
After this you have to parse the data you required.
public Form1()
{
InitializeComponent();
WebRequest webRequest = WebRequest.Create(“http://www.yahoo.com”);
WebResponse webResponse = webRequest.GetResponse();
Stream stream = webResponse.GetResponseStream();
StreamReader streamReader = new StreamReader(stream);
string line;
while ( (line = streamReader.ReadLine()) != null)
{
listBox1.Items.Add(line);
}
stream.Close();
}