473,698 Members | 2,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Download File(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 7374
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.QueryStr ing = qs;
Client.Download File(url, save_as);

--
Greg Ewing [MVP]
http://www.citidc.com
"Du Dang" <he**********@r ogers.com.BAM> wrote in message
news:_r******** ********@news04 .bloor.is.net.c able.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.Download File(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**********@r ogers.com.BAM> wrote in message
news:_r******** ********@news04 .bloor.is.net.c able.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.Download File(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**********@r ogers.com.BAM> wrote in message
news:_r******** ********@news04 .bloor.is.net.c able.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.Download File(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
8532
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 all works fine. If the user selects "Open" or "Cancel", the window closes, which is the desired behavior. If they select "Save", the location dialog shows up, they save the file and the window remains open. I've tried a number of things to get...
0
2579
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 http://www.site.com/download This download page contains some textboxes, checkboxes, radiobuttons, a DOWNLOAD BUTTON and text 3. I check some checkboxes, select some radiobuttons, enter text in some textboxes and click on the download button
0
1828
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 window. Well, thanks to Steve Orr, I have that working. However, I still have a few issues. First, the download dialog does not have the name of the file being downloaded in the "File name" field, instead it has the name of the aspx page that have...
3
1637
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 that the record was deleted I am able to do any of these things separately with no trouble. The problem occurs when I try to offer a download AND call my refresh method. When I try to do a download and call my refresh method, only the download is...
18
16395
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 completely automatically what, until now, I do manually, witch is describe below : 1. I launch IE (6)
1
3576
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 out whole script, just a part if file won't download in 2mins then skip to the next one. Previously, I had a Javascript implementation with AJAX, this time I thought of doing it in PHP since PHP has far better array functions, I don't have to do...
16
3248
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 not print in the username or email amddress of the person doing the download - which I am collecting from a form on the previous page. I can get the name and email address to print out normally, just not into the email sending body. I have...
1
2170
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 ringtone popular ringtine download ringtone download verizon ringtone download cingular ringtone download mosquito ringtone download mp3 ringtone download nextel ringtone download verizon ringtone download nokia ringtone download midi ringtone mobile...
5
3683
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... so i used Response.WriteFile but it won't trigger any download manager such as DAP or FlashGet i used this code :
1
47462
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 on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
8676
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
8608
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,...
1
8898
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
8870
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
7734
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
4370
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...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3051
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
2006
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.