473,396 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I download with c# ?

i wanna create a bot to download wallpaper from a website
cuz there are thousands of pic availiable and right click and "save as"
ain't fun no more

so far i got this from google

+++++++++++

WebClient Client = new WebClient();
Client.DownloadFile(url, save_as);

+++++++++++

but that code can only download static url only
ie. http://www.google.ca/intl/en_ca/images/logo.gif

but it doesn't work for links like
http://www.themexp.org/download.php?type=wp&id=96
it keep giving me http 400 error (bad request)

any help is appreciated

thanks

Du
Nov 15 '05 #1
3 7343
Du, have you tried to set the QueryString property of the WebClient object?
So, your code would look like this:
string url = "http://www.themexp.org/download.php";
string qs = "?type=wp&id=96";
WebClient Client = new WebClient();
Client.QueryString = qs;
Client.DownloadFile(url, save_as);

--
Greg Ewing [MVP]
http://www.citidc.com
"Du Dang" <he**********@rogers.com.BAM> wrote in message
news:_r****************@news04.bloor.is.net.cable. rogers.com...
i wanna create a bot to download wallpaper from a website
cuz there are thousands of pic availiable and right click and "save as"
ain't fun no more

so far i got this from google

+++++++++++

WebClient Client = new WebClient();
Client.DownloadFile(url, save_as);

+++++++++++

but that code can only download static url only
ie. http://www.google.ca/intl/en_ca/images/logo.gif

but it doesn't work for links like
http://www.themexp.org/download.php?type=wp&id=96
it keep giving me http 400 error (bad request)

any help is appreciated

thanks

Du

Nov 15 '05 #2
Du,

The second URL returns a page with a redirect of some sort (http header or
javascript) that causes Internet Explorer to download the file. It's not a
direct link to the file. The reason it's like this is that the creators of
the website wanted to prevent people like you from automated downloading
like you're trying to do. If you decide not to respect their wishes, then
there's certainly a way to get the file anyway. It's possible that the
server is rejecting the request from your code to download the second link
because of the information sent in the HTTP header. Specifically, the
themexp server could be checking which client you're using to make sure it's
a browser. You'll have to spoof the header of the request sent using
WebClient somehow. I don't know if that's easily possible or not. You may
have to use a different library to send the web request, or do it yourself
using sockets. But it's a direction for you.

Chris

"Du Dang" <he**********@rogers.com.BAM> wrote in message
news:_r****************@news04.bloor.is.net.cable. rogers.com...
i wanna create a bot to download wallpaper from a website
cuz there are thousands of pic availiable and right click and "save as"
ain't fun no more

so far i got this from google

+++++++++++

WebClient Client = new WebClient();
Client.DownloadFile(url, save_as);

+++++++++++

but that code can only download static url only
ie. http://www.google.ca/intl/en_ca/images/logo.gif

but it doesn't work for links like
http://www.themexp.org/download.php?type=wp&id=96
it keep giving me http 400 error (bad request)

any help is appreciated

thanks

Du

Nov 15 '05 #3
Thanks to Greg and Chris for helping me out...

I haven't get it to work yet .. but now i have a lead to follow

thanks again !!!

"Du Dang" <he**********@rogers.com.BAM> wrote in message
news:_r****************@news04.bloor.is.net.cable. rogers.com...
i wanna create a bot to download wallpaper from a website
cuz there are thousands of pic availiable and right click and "save as"
ain't fun no more

so far i got this from google

+++++++++++

WebClient Client = new WebClient();
Client.DownloadFile(url, save_as);

+++++++++++

but that code can only download static url only
ie. http://www.google.ca/intl/en_ca/images/logo.gif

but it doesn't work for links like
http://www.themexp.org/download.php?type=wp&id=96
it keep giving me http 400 error (bad request)

any help is appreciated

thanks

Du

Nov 15 '05 #4

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

Similar topics

6
by: chon | last post by:
I have an ASP page that is sent a file location as a parameter. It opens this file, loads the ADODB.Stream object and does a binary write to the page forcing the download dialog to appear. This...
0
by: jmd | last post by:
Hello. I want to write a C# program that does completely automatically what, until now, I do manually, witch is describe below : 1. I launch IE (6) 2. I browse to my desired download page, say...
0
by: Buddy Ackerman | last post by:
I am trying to implment a file download via a link such that when clicked, instead of starting the default application for that type of file the user will be presented with a download dialog...
3
by: Nathan Sokalski | last post by:
I have a webform that contains a button which I want to do three things: 1. Delete a record from a database 2. Let the user download a text file that is generated 3. Refresh the page to show...
18
by: jmd | last post by:
Hello, I posted the following in the C# forum but without one answer. But perhaps now in vb.net someone has some guidelines ! This is my question : I want to write a vb.net program that does...
1
by: a.r.austin | last post by:
Hello, I am trying to download a few files one after another from a remote server. Problem is that I don't know how to, or if I am able at all, set a time out for download. I don't want to time...
16
by: matt | last post by:
I have used some free code for listing files for download, but I want to send an email to the administrator when the file has been downloaded. I have got some code in here that does it, but it will...
1
by: JayLembeck | last post by:
Over 50,000 Free Ringtone. Get the Latest Ringtone. Download now- Fast, Free and Easy. Get your FREE surprise RINGTONE now! http://seekoutfast.info/free-ringtone/ free ringtone free ringtone new...
5
by: Khafancoder | last post by:
Hi guys, i am building a FileSharing website, i wanna allow users to be able using download managers such as DAP to download files from webserver but don't allow them to retrive files url......
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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,...
0
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,...
0
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...
0
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 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.