473,796 Members | 2,669 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 2918
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
8570
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
11590
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
10336
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
9530
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
10459
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10182
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10017
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...
1
7552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6793
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
5445
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4120
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
2928
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.