Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi all.i use this code to capture a website .
C#
string downloadString = client.DownloadString("http://www.google.com");

the thing that i want is near the first of the page.this site is an example.but in my website each page contain many elements that makes its heavy .i want to optimize my C# programe . i mean instead of capturing all webpage ,capture for example till div with a class of nav .

i know how to capture whole of it .but i do not want to use it.let explain it.i have a webpage that contain 50000 lines of code.my special code is in the first line.i want to know is there any way while downloading webpage , search for my code.when it see's the first line and detected that code , stop downloading rest of the page and just bring me the first line.in this cases you can download just one line not whole webpage.is there any way?
Posted
Updated 19-Feb-14 3:05am
v2
Comments
ZurdoDev 18-Feb-14 17:04pm    
The only way I am familiar with is to parse it using regular string methods. Is there not a webservice available to give you what you need?
Farshad72 18-Feb-14 17:21pm    
regular is used after we capture website,am i right?
ZurdoDev 18-Feb-14 17:22pm    
Yes, I don't know of any way to only get a portion of the page initially. You'll have to get the whole string and then parse it.
Sergey Alexandrovich Kryukov 18-Feb-14 21:06pm    
It sounds like you know how to capture whole Website. No, it is not the case. You don't. What's the problem? What have you tried so far?

—SA
Farshad72 19-Feb-14 1:49am    
i know how to capture whole of it .but i do not want to use it.let explain it.i have a webpage that contain 50000 lines of code.my special code is in the first line.i want to know is there any way while downloading webpage , search for my code.when it see's the first line and detected that code , stop downloading rest of the page and just bring me the first line.in this cases you can download just one line not whole webpage.is there any way?

 
Share this answer
 
Comments
Farshad72 18-Feb-14 18:06pm    
i'v checked first link.it is useful but i think it should be used after capturing whole site
You are interested in something called Web scraping: http://en.wikipedia.org/wiki/Web_scraping[^].

Please see my past answer: get specific data from web page[^].

See also this one: How to get the data from another site[^].

—SA
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900