Click here to Skip to main content
13,091,145 members (81,792 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have a doubt I am developing a website i need the details from another site how can i get that.........

For Example:if my user what to check the details of a train i want to get the details from another site is this possible..If possible how can i get it..

Train No:..........(user specified)

Details of the train(details should come from another site to my site)


I have heard that this is possible my HTTP Request and HTTP Response..

Please tell the how can we use that and get the details or is ther any other method..

Thanks in advance...
Posted 15-Jun-11 5:10am
SAKryukov 15-Jun-11 22:10pm
Is it ASP.NET? Tag it!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

There are two ways to do this:
- If the site you want to take data from has a public web service API, use that. Ask the owner of the site if there isn't one advertised, they may have one you can use.
- If not, you can 'visit' the site with WebRequests and parse the information you want out of the result. Depending on the makeup of the site, this can be trivial or almost impossible (for example if the information is retrieved dynamically through Javascript and you don't have access to the feed yourself). Before doing this, check the terms of use of the site (or ask the owner), because it adds significant load to their site and many people don't like you doing it.
vinayraju 15-Jun-11 11:37am
Thanks for the information.........
somayeh151 1-Jan-14 16:20pm
Thank you.i am working on your answer...
SAKryukov 15-Jun-11 22:22pm
That's correct, my 5.
See also my detailed solution on your #2.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

If you have heard of HttpWebRequest, why not using it? This is a correct way.

Compile-time type should be System.Net.WebRequest though, as the run-time type is defined by the Uri parameter passed to its factory method System.Net.WebRequest.WebRequest.Create.

See the code sample here:[^], see also[^].

See these articles:
How to use HttpWebRequest and HttpWebResponse in .NET[^],
HttpWebRequest/Response in a Nutshell - Part 1[^].

RMSinha 28-Jul-15 6:49am
Thanks i got it....
You are welcome. So, will you accept the answer formally?
RMSinha 29-Jul-15 5:41am
yes but some small changes i have done and finally i got it....
Sergey Alexandrovich Kryukov 29-Jul-15 10:18am
Very good, but will you accept the answer?
Rate this: bad
Please Sign up or sign in to vote.

Solution 7

		StringBuilder sb  = new StringBuilder();
		byte[]        buf = new byte[8192];
		HttpWebRequest  request  = (HttpWebRequest)
		HttpWebResponse response = (HttpWebResponse)
		Stream resStream = response.GetResponseStream();
		string tempString = null;
		int    count      = 0;
			count = resStream.Read(buf, 0, buf.Length);
			if (count != 0)
			tempString = Encoding.ASCII.GetString(buf,0,count);
				// continue building the string
		while (count > 0); // any more data to read?
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

I think, If the other site provide you webservice then you can use this webservice in your project by passing the required argumnet.
Rate this: bad
Please Sign up or sign in to vote.

Solution 6

you can do it. first you record process by httpwatch or in IE9 (Press F12) and get the details of url, refer, accept, request body and resposnse. than in use these information by using here is simple example

public string siteOutput(string url,string Method,string refer,string ContentType,string reqBody)
        HttpWebRequest request;
        HttpWebResponse response;
CookieContainer coo = new CookieContainer();
request.CookieContainer = coo;
                request = (HttpWebRequest)WebRequest.Create(url);
                request.Method =Method; //"POST";
                request.Referer =refer; //"http://www.YourSite";
                request.ContentType = ContentType; //"application/x-www-form-urlencoded";
                //request.Headers.Add("Cookie", c0 + ";" + c1);
                poststring =reqBody; //"loginId=" + loginId + "&email=" + email + "&unitName=" + unitName + "&designation=" + designation + "&firstName=" + firstName + "&middleName=&lastName=singh&phoneNumber=&mobileNumber=";
                using (Stream sm = request.GetRequestStream())
                    byte[] databyte = System.Text.Encoding.ASCII.GetBytes(poststring);
                    sm.Write(databyte, 0, (int)databyte.Length);
                response = (HttpWebResponse)request.GetResponse();
                string strPageOutPut = new StreamReader(response.GetResponseStream()).ReadToEnd();
return strPageOutPut

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 8 Dec 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100