I want to do a very simple thing -- hit a website and retrieve the html it
gives me (in C#). I have to admit I'm a little lost within the MSDN
documentation. The best I can figure is I should use
HttpWebRequest.Create(URL) to being setting up the connection, but I don't
know where to go from there. Are there any online docs that show sample code
to retrieve the html that's returned? Or, what's the sequence of calls to
finally get a string representation of the page?
Thanks in advance 11 1906
Hi, http://groups.google.com/groups?hl=e...phx.gbl&rnum=5
Or just make a search for HttpWebRequest Stream
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"axis" <ju********************@nospam.com> wrote in message
news:Aez4d.241303$Fg5.147680@attbi_s53... I want to do a very simple thing -- hit a website and retrieve the html it gives me (in C#). I have to admit I'm a little lost within the MSDN documentation. The best I can figure is I should use HttpWebRequest.Create(URL) to being setting up the connection, but I don't know where to go from there. Are there any online docs that show sample
code to retrieve the html that's returned? Or, what's the sequence of calls to finally get a string representation of the page?
Thanks in advance
Hi Axis,
It requires a few steps. The following code is the basic way to do it, not using any headers
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com");
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
// get the text (StreamReader uses UTF-8 by default, but you can change it)
string html = sr.ReadToEnd();
//close the streams
sr.Close();
resp.Close();
--
Happy Coding!
Morten Wennevik [C# MVP]
Is there a way to do what you've done (navigate to a specific webpage) and
then take a "screenshot" programatically? For example, going to the main
CSI (ya, tv show :>) website with numerous pictures, formatting, etc, and
take a screenshot or paint it to a panel/canvas/window and then save that to
a jpeg?
Thanks.
On Thu, 23 Sep 2004 09:45:42 -0400, Flip <[remove]ph******@hotmail.com> wrote: Is there a way to do what you've done (navigate to a specific webpage) and then take a "screenshot" programatically? For example, going to the main CSI (ya, tv show :>) website with numerous pictures, formatting, etc, and take a screenshot or paint it to a panel/canvas/window and then save that to a jpeg?
No, because this method will retrieve the source code of the page only, images and stuff are linked and rendered before displayed in a browser.
You may be able to use the ActiveX Web Browser object to open the page and take a screenshot of it, not sure.
--
Happy Coding!
Morten Wennevik [C# MVP]
I may be wrong, but I'm thinking you can't do that - at least not without an
interface. To do a screenshot, you need to take a picture of what is
actually being rendered to the screen. If it's not visible, you can't
capture it. If you don't mind a window popping up, you could open IE, size
the window accordingly (or put into kiosk mode), then take a screenshot, is
that what you want? Does the jpeg need to be a certain size? Can it be the
whole desktop area?
"Flip" <[remove]ph******@hotmail.com> wrote in message
news:Om**************@TK2MSFTNGP11.phx.gbl... Is there a way to do what you've done (navigate to a specific webpage) and then take a "screenshot" programatically? For example, going to the main CSI (ya, tv show :>) website with numerous pictures, formatting, etc, and take a screenshot or paint it to a panel/canvas/window and then save that
to a jpeg?
Thanks.
Howdy. That was quick! :> I may be wrong, but I'm thinking you can't do that - at least not without
an interface. To do a screenshot, you need to take a picture of what is
Is there sometype of object that does that? Sorry for the newbie type
questions, I'm coming from java and am trying to learn c# and .net at the
sametime. I thought making a dynamic screensaver would be cool.
the window accordingly (or put into kiosk mode), then take a screenshot,
is that what you want? Does the jpeg need to be a certain size? Can it be the whole desktop area?
Right now, I am just looking to see a rough idea if it can be done. Any
size is good! :> haha
Thanks.
Hi Axis,
Here's an article I wrote on this: http://www.csharp-station.com/HowTo/HttpWebFetch.aspx
Joe
-- http://www.csharp-station.com
"axis" <ju********************@nospam.com> wrote in message
news:Aez4d.241303$Fg5.147680@attbi_s53... I want to do a very simple thing -- hit a website and retrieve the html it gives me (in C#). I have to admit I'm a little lost within the MSDN documentation. The best I can figure is I should use HttpWebRequest.Create(URL) to being setting up the connection, but I don't know where to go from there. Are there any online docs that show sample
code to retrieve the html that's returned? Or, what's the sequence of calls to finally get a string representation of the page?
Thanks in advance
Here's a place to start, here's how to create a screenshot of your own form: http://www.syncfusion.com/FAQ/WinFor..._c3c.asp#q870q
Oh wait, you could put a browser on a Windows form and use this code
exactly? Seems like a place to start?!
"Flip" <[remove]ph******@hotmail.com> wrote in message
news:up*************@TK2MSFTNGP11.phx.gbl... Howdy. That was quick! :>
I may be wrong, but I'm thinking you can't do that - at least not
without an interface. To do a screenshot, you need to take a picture of what is Is there sometype of object that does that? Sorry for the newbie type questions, I'm coming from java and am trying to learn c# and .net at the sametime. I thought making a dynamic screensaver would be cool.
the window accordingly (or put into kiosk mode), then take a screenshot, is that what you want? Does the jpeg need to be a certain size? Can it be
the whole desktop area? Right now, I am just looking to see a rough idea if it can be done. Any size is good! :> haha
Thanks.
Morten Wennevik wrote: Hi Axis,
It requires a few steps. The following code is the basic way to do it, not using any headers
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com");
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
// get the text (StreamReader uses UTF-8 by default, but you can change it) string html = sr.ReadToEnd();
//close the streams sr.Close(); resp.Close();
Thanks! That's precisely the code I needed.
Now, normally if I were in C or C++ I'd go into building my custom HTML
parser -- I'm trying to extract data from an html page with predictable
design (i.e. content I want is always in particular locations in the
html heirarchy). Anyway, .Net is awesome in the sheer number of utility
classes already built, so the followup question -- is there a utility
class where I can feed in the HTML and it'll allow me to browse it
programatically? Similarly to the XMLDocument class for XML? I know
technically I could feed a well formed HTML page as XML, but I can
guarantee this page isn't well formed. Otherwise, I'll have lots of fun
writing regexps and substring ops.
Thanks again!
- Axis This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: paul fpvt2 |
last post by:
How can I read a file from a website ?
For example, I would like to read
http://www.website.com/news.htm, can I do that ?
Thanks.
|
by: grzecho |
last post by:
I'd like to read website HTML code in my program. How can I do it ???
What to do when I must write login and password on this website before read
??
sory that my english is not very good but I...
|
by: Shawn B. |
last post by:
Greetings,
I have have been working for almost 18 months on a set of WebControls where
some are similar to the ASP.NET standard and well-enhanced while other
controls are completely new and...
|
by: who be dat? |
last post by:
I feel stupid for asking this but I can't figure this out. I've got some
text files I want my website to read. The text files are located in a
subdirectory of my application. Physically, the...
|
by: David |
last post by:
SUMMARY: If you don't want to read all of this, what I'm looking for
more or less is ideas on how to implement websites using ASP.NET that
have a templated look and feel and many pages that make...
|
by: Erik Sandblom |
last post by:
Hello
I can't read the London & Continental Railways website and they have no
email address to complain to. I tried calling them, but got put through to
one guy who hung up, and another who had...
|
by: phil2phil |
last post by:
Hi,
I wanted to know if there is any example or library that I could look
at to help me write an application that could read the html code from a
website. We currently have a site that display...
|
by: sid |
last post by:
Hi,
I am designing a website for our college students to buy and sell
things on this site. It is supposed to be a non commercial website.
I want to write the code in php as my college website...
|
by: Wayne Smith |
last post by:
Applies to: Visual Studio 2008 Professional
Hi everyone,
I'm in the middle of creating a website with VS2008 and I'm trying to integrate a user registration/login section on the website but I've...
|
by: neovantage |
last post by:
Hey all,
I want to read news and reviews from a website
http://carsguide.news.com.au/site/rss/
and want to populate on my website. How can i read that rss and show on my website using php
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |