If you want to get the search result which is present on that page as HTML, you need to get the page using HttpWebRequest and httpWebResponse and
then parse those search results for example they may be present inside a div with id='searchDiv' so you need to get text inside this tag.
i have converted this vb code into c# , i got this code from this link http://aspnetlibrary.com/articledetails.aspx?article=Retrieve-data-from-a-web-page, this is post method() code....
Then where i want to write this code in web form submit button... ah ? i want to give 3textbox input and give search, i want output from this website
http://www.ticketgoose.com/ search....
Imports System.IO
Imports System.Net
Partial Class Default1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strURL As String = ""
Dim strPostData As String = ""
Dim strResult As String = ""
Dim wbrq As HttpWebRequest
Dim wbrs As HttpWebResponse
Dim sw As StreamWriter
Dim sr As StreamReader
' Set the URL to post to
strURL = "http://www.webcom.com/cgi-bin/form"
' Post some values to the page
strPostData = String.Format("your_name={0}&userid={1}&form_name={2}", "Mark Smith", "webcom", "tutortest")
' Create the web request
wbrq = WebRequest.Create(strURL)
wbrq.Method = "POST"
' We don't always need to set the Referer but in this case
' the page we are posting to will only issue a response if we do
wbrq.Referer = "http://www.webcom.com/cgi-bin/form"
wbrq.ContentLength = strPostData.Length
wbrq.ContentType = "application/x-www-form-urlencoded"
' Post the data
sw = New StreamWriter(wbrq.GetRequestStream)
sw.Write(strPostData)
sw.Close()
' Read the returned data
wbrs = wbrq.GetResponse
sr = New StreamReader(wbrs.GetResponseStream)
strResult = sr.ReadToEnd.Trim
sr.Close()
' Write the returned data out to the page
TextBox1.Text = strResult
End Sub
End Class
Well this can be done if you can figure out how ticketgoose is sending search requests, if they are passing search values in querystring you can build a similar one and send and get back details, if not then you better check their site for some API they
have offered for developers to work upon.
<div class="dp-highlighter nogutter"> <div class="bar">its not converting correctly it shows error to convert c#: error is: -- line 30 col 1: EOF expected</div> <div class="bar">http://www.developerfusion.com/tools/convert/vb-to-csharp/ </div>
Imports System.IO
Imports System.Net
PartialClass Default1
Inherits System.Web.UI.Page
ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.Load
maddyrafi897...
Member
134 Points
300 Posts
try to help
Apr 30, 2012 04:55 AM|LINK
How to get data from other website ?
can i use this coding for that ?
http://aspnetlibrary.com/articledetails.aspx?article=Retrieve-data-from-a-web-page
patuary
Member
425 Points
143 Posts
Re: try to help
Apr 30, 2012 04:58 AM|LINK
i cannot understand. do u mean website scraping?
maddyrafi897...
Member
134 Points
300 Posts
Re: try to help
Apr 30, 2012 04:59 AM|LINK
yes, i want to take search result from other website page how ?
nijhawan.sau...
All-Star
16460 Points
3178 Posts
Re: try to help
Apr 30, 2012 05:01 AM|LINK
Yes these HttpWebRequest and httpWebResponse can be used to retreive resulting HTML from a webpage.
If you want to get the search result which is present on that page as HTML, you need to get the page using HttpWebRequest and httpWebResponse and then parse those search results for example they may be present inside a div with id='searchDiv' so you need to get text inside this tag.
maddyrafi897...
Member
134 Points
300 Posts
Re: try to help
Apr 30, 2012 05:03 AM|LINK
Thank you so much.... but i want to convert that code into c# how ?
nijhawan.sau...
All-Star
16460 Points
3178 Posts
Re: try to help
Apr 30, 2012 05:09 AM|LINK
VB to C# code convertor:
http://www.developerfusion.com/tools/convert/vb-to-csharp/
maddyrafi897...
Member
134 Points
300 Posts
Re: try to help
Apr 30, 2012 05:26 AM|LINK
i have converted this vb code into c# , i got this code from this link http://aspnetlibrary.com/articledetails.aspx?article=Retrieve-data-from-a-web-page, this is post method() code....
Then where i want to write this code in web form submit button... ah ? i want to give 3textbox input and give search, i want output from this website http://www.ticketgoose.com/ search....
Imports System.IO
Imports System.Net
Partial Class Default1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strURL As String = ""
Dim strPostData As String = ""
Dim strResult As String = ""
Dim wbrq As HttpWebRequest
Dim wbrs As HttpWebResponse
Dim sw As StreamWriter
Dim sr As StreamReader
' Set the URL to post to
strURL = "http://www.webcom.com/cgi-bin/form"
' Post some values to the page
strPostData = String.Format("your_name={0}&userid={1}&form_name={2}", "Mark Smith", "webcom", "tutortest")
' Create the web request
wbrq = WebRequest.Create(strURL)
wbrq.Method = "POST"
' We don't always need to set the Referer but in this case
' the page we are posting to will only issue a response if we do
wbrq.Referer = "http://www.webcom.com/cgi-bin/form"
wbrq.ContentLength = strPostData.Length
wbrq.ContentType = "application/x-www-form-urlencoded"
' Post the data
sw = New StreamWriter(wbrq.GetRequestStream)
sw.Write(strPostData)
sw.Close()
' Read the returned data
wbrs = wbrq.GetResponse
sr = New StreamReader(wbrs.GetResponseStream)
strResult = sr.ReadToEnd.Trim
sr.Close()
' Write the returned data out to the page
TextBox1.Text = strResult
End Sub
End Class
nijhawan.sau...
All-Star
16460 Points
3178 Posts
Re: try to help
Apr 30, 2012 05:35 AM|LINK
Well this can be done if you can figure out how ticketgoose is sending search requests, if they are passing search values in querystring you can build a similar one and send and get back details, if not then you better check their site for some API they have offered for developers to work upon.
maddyrafi897...
Member
134 Points
300 Posts
Re: try to help
Apr 30, 2012 05:44 AM|LINK
- Imports System.IO
- Imports System.Net
- Partial Class Default1
- Inherits System.Web.UI.Page
-
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Dim strURL As String
- Dim strResult As String
- Dim wbrq As HttpWebRequest
- Dim wbrs As HttpWebResponse
- Dim sr As StreamReader
-
- ' Set the URL (and add any querystring values)
- strURL = "http://aspnetlibrary.com/articles.aspx?Page=1"
-
- ' Create the web request
- wbrq = WebRequest.Create(strURL)
- wbrq.Method = "GET"
-
- ' Read the returned data
- wbrs = wbrq.GetResponse
- sr = New StreamReader(wbrs.GetResponseStream)
- strResult = sr.ReadToEnd.Trim
- sr.Close()
-
- ' Write the returned data out to the page
- TextBox1.Text = strResult
- End Sub
- End Class
</div>kalyanns
Member
253 Points
277 Posts
Re: try to help
Apr 30, 2012 05:46 AM|LINK
Vat's Ur Actual project mate..........!!!
Do FEAR (Face Everything And Rise)