如何用C#写代码批量下载网页上提供的附件。

在一个网页上有一个导出PDF文件的功能,是当点击这个按钮后,执行一个脚本,然后弹出文件下载另存为的对话框进文件的下载功能。
现在希望用C#实现自动批量的下载并保存这些PDF文件。
求实现方法,谢谢!

用webclient.downloadfile或者httpwebrequest去下载。

建议压缩成ZIP包后再下载。

执行的是一个脚本,现在我可以实现通过代码模拟这个单击操作,执行这个脚本,但是如何能得到下载文件的路径呢?
用webClient.Download 与 httpWebRequest只能请求到整个网页数据呀。

用webclient.downloadfile是最方便的用法

主要是我没有获取到下载的地址,是网页上是通过脚本去下载的。

 /// <summary>        
        /// FileDownLoad方法
        /// </summary>
        /// <param name="URL">下载文件地址</param>
        /// <param name="Filename">下载后的存放地址</param>
        /// <param name="Prog">用于显示的进度条</param>
        public void DownloadFile(string URL, 
                string filename, 
                ProgressBar prog, 
                Label label1) {
            float percent = 0;
            try
            {
                System.Net.HttpWebRequest Myrq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(URL);
                System.Net.HttpWebResponse myrp = (System.Net.HttpWebResponse)Myrq.GetResponse();
                long totalBytes = myrp.ContentLength;
                if (prog != null)
                {
                    prog.Maximum = (int)totalBytes;
                }
                System.IO.Stream st = myrp.GetResponseStream();
                System.IO.Stream so = new System.IO.FileStream(filename, System.IO.FileMode.Create);
                long totalDownloadedByte = 0;
                byte[] by = new byte[1024];
                int osize = st.Read(by, 0, (int)by.Length);
                while (osize > 0)
                {
                    totalDownloadedByte = osize + totalDownloadedByte;
                    System.Windows.Forms.Application.DoEvents();
                    so.Write(by, 0, osize);
                    if (prog != null)
                    {
                        prog.Value = (int)totalDownloadedByte;
                    }
                    osize = st.Read(by, 0, (int)by.Length);
                    percent = (float)totalDownloadedByte / (float)totalBytes * 100;
                    label1.Text = "下载进度:" + percent.ToString() + "%";
                    System.Windows.Forms.Application.DoEvents();
                }
                so.Close();
                st.Close();
            }
            catch (Exception exc) { MessageBox.Show("下载文件失败。+\r\n+exc.ToString()"); }
        }