473,804 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Picturebox, Image.FromStrea m, WebRequest - Doesn't allways work

Hello Sirs

I hope you can give me a hint to this little problem.

The thing is, I have for a lang time enjoyed the comics on www.washintonpost.com,
and I allways start the day by going to their homepage.

One day, I thought: Why not just make a little program in C#, that
just shows me the .gif-picture of the strip?
And so I did. Or, more correctly, I tried to do.

Actually, it's quite simple. I want to show the strip of "Non
Sequitur" from the 30. of may 2008.
It can be seen directly in a browser, using this link:

http://wpcomics.washingtonpost.com/c...nq/2008/05/30/

Showing "Properties " thell me, the link directly to the .gif-file is
this:

http://wpcomics.washingtonpost.com/f...0/nq080530.gif

The strip can be viewed in a picturebox this way:

picturebox1.Ima ge = Image.FromStrea m(WebRequest.Cr eate("http://
wpcomics.washin gtonpost.com/feature/08/05/30/
nq080530.gif"). GetResponse().G etResponseStrea m());

If I want another strip from another date, I just change the date-part
of the url.

So far, so good.

However, I'd like to see "Hagar the Horrible" too. Browser link to the
same date is:

http://www.washingtonpost.com/wp-srv...&date=20080530

But here starts the problem: "Properties " on the strip is:

http://est.rbma.com/content/Hagar_Th...?date=20080530

Directly in a browser, it works fine.
But using it in a picturebox does not!

What can I do to make this work??
Any constructive input is welcome!

(It _should_ be possible! A friend told me once, that anything other
programs can do, I can do too in C#.)

Sincerely / Best regards
Mads Aggerholm
Jun 27 '08
12 2919
Hi Parez,

Thanks for the suggestion:
>
HttpWebRequest * *request = (HttpWebRequest )WebRequest.Cre ate("http://
est.rbma.com/content/Hagar_The_Horri ble?date=200805 30");

* * * * * * request .Referer="Somec rap.com";

so instead of somecrap.com OP (i dont know what that means) will have
to use *washtingtonpos t.com- Skjul tekst i anførselstegn -
But how do I get this into the picturebox??

I tried this:

HttpWebRequest request = (HttpWebRequest )WebRequest.Cre ate("http://
est.rbma.com/content/Hagar_The_Horri ble?date=200805 30");
request .Referer="washi ngtonpost.com";
picturebox1.Ima ge =
Image.FromStrea m(request).GetR esponse().GetRe sponseStream()) ;

Wild guess, I thought it would work that way, but it didn't.

Sincerely / Best regards
Mads Aggerholm

Jun 27 '08 #11
Hi Pete,
Personally, it's my opinion that when one starts impersonating a web page,*
they are getting into a gray area with respect to content/copyright *
ethics. *The web server owner is clearly specifically interested in making *
sure that when you look at the comic, you do so in a particular context. *
When you impersonate that context, you break the implied contract with the*
content producer.

*From the content producer's point of view, that contract may involve *
ensuring that advertising or other contextual things that they deem *
important or financially necessary are included. *If you as the viewer *
aren't willing to abide by that contract, then you're basically saying you*
don't approve of the "sale", and thus shouldn't be "buying" (that is, just*
don't read the comic).

As far as I know, this is not technically illegal per se. *But it *
definitely seems a little "wrong" to me. *From an implementation point of *
view, this could be avoided by just using the WebBrowser control and *
displaying the entire original page rather than just the comic. *That *
would also automatically fix the "referrer" issue. *:)
I understand your thoughts on this issue, and I - partly - agree.
To my excuse, I can mention that I read those comics on the Post and
nothing else. The commercials, which is what the post wants me to
read, does not apply to me, since I am living in Denmark, and as I see
it, it's not much different from using an application that hides the
commercials on websites.

This project is something has it's offspring in the thougt, that it
would be interesting to see if it could be done.
That last part of the sentence is the greatest teacher in the world.
I have learned a million things that way.

Sincerely / Best regards
Mads Aggerholm

Jun 27 '08 #12
Ok, got it solved:

string myUri = "http://est.rbma.com/content/
Hagar_The_Horri ble?date=200805 26";
HttpWebRequest myHttpWebReques t =
(HttpWebRequest )WebRequest.Cre ate(myUri);
myHttpWebReques t.Referer = "http://www.washingtonp ost.com/
wp-srv/artsandliving/comics";
try
{ HttpWebResponse myHttpWebRespon se =
(HttpWebRespons e)myHttpWebRequ est.GetResponse ();
Stream streamResponse =
myHttpWebRespon se.GetResponseS tream();
Image im = Image.FromStrea m(streamRespons e);
streamResponse. Close();
myHttpWebRespon se.Close();
picturebox1.Ima ge = im;
}
catch
{
MessageBox.Show ("Failure!") ;
}

Thanks for the input, everybody!

Sincerely / Best regards
Mads Aggerholm

Jun 27 '08 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12994
by: thedebugger | last post by:
Dear Friends, I am making one RSS News Reader Desktop application in c#. Where I will show the images from website. I am generating xml file on server. like http://www.zeetelevision.com/myxml.xml Problem is PictureBox1.Image = Image.FromFile("http://www.zeetelevision.com/images/today.jpg"); Its giving me error, URI path not supported..
6
8572
by: Saya | last post by:
Hello, This is a repost 'cause I haven't solve the problem: I can't use the System.Drawing class 'Image.FromStream' in the CompactFramework environment. What I've done with respect to Brendan's suggestion is as follows: Brendan, thanks for the reply! I'm a little bit further now, but not yet finished. I've come this far, see code below: Stream s =
1
11592
by: wschlichtman | last post by:
I'm attempting to retrieve a bitmap from an image field in SQL Server 2005 using Visual Studio 2005 C#. I then want to load the bitmap into a picturebox. When I run the following code, I get the error message: Parameter is no valid. Debugging shows that the Image.FromStream(ms) statement is the culprit. Anyone know what I'm doing wrong?
17
4661
by: Jan Nielsen | last post by:
Hi I would like to databind a Picturebox to a SQL Server. I have a typed Dataset "DSBoernekirken1" It has a table named "tpersoner" with a column "Photo" I of course would like to bind the image directly to tpersoner.photo using Properties (like I do with text fields), but this does not seem to be possible. Then I searched some news groups and Knowledgebase and found the following
2
3755
by: Mark | last post by:
Hello, Say I write a picture file to: 'c:\test.jpg' Then I assign this picture to a picturebox PbFoto.Image = Image.Fromfile("c:\test.jpg") Next I want the overrwrite the file test.jpg with another picture. When running, he says the file is in use when I want to overwrite it.
7
11910
by: Gary Shell | last post by:
I have a column named "PictureImage" in a SQL database defined as datatype=image. It has a Bitmap picture in it. (I verified the type by creating an Access project and a looking at the data, which access reports as "Bitmap Image".) In my VB.NET app I use the following code: Dim bytBLOBData() As Byte = Me.datasetProduct.Tables("Product").Rows(0)("PictureImage") Dim stmBLOBData As New MemoryStream(bytBLOBData)
8
10337
by: ..:: Kevin ::.. | last post by:
If I load a PictureBox image from an embedded resource within my application it works fine but if I load the same image from a file using OpenFileDialog (as an ImageStream or using the file name) the background color is not masked out. Any ideas?
4
10517
by: John Daly | last post by:
Does anyone know how to create an image (JPEG) from an HTTPResponse object? I am working on system that has a map pop up from our GIS department. I want create an image at runtime from this popup and display that image on the main page instead of opening a new window. This image will be a memory stream only, but will need to be kept from page to page, and printer if required. Any help will be much appreciated. If anyone knows of any...
3
2035
by: Brandon Arnold | last post by:
I'm having an issue that I can't quite figure out. I have a PictureBox that initially sets a picture from an embedded resource. The user clicks a listview item and if an image url is available, it sets the ImageLocation property to the url of the image and loads it. Then if the user clicks a ListView item without an image url, the default embedded image is displayed. This all works great, but if I click an item with an image url, then...
0
9716
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10354
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10101
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9177
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6870
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3005
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.