Sina Flash download tool [HttpWebRequest | Sina Video]

Source: Internet
Author: User

 

Preface

Haha, I haven't written any gadgets for a long time. The stupid pictures I wrote last year batch download tool V0.3 beta is still a little helpful. Today's gadgets are Sina Flash downloads. Can directly download the swf end of the file, if you download Sina video files, you need to right-click the source code to find this flash pseudo link, such as http://music.sina.com.cn/yueku/flashPlayer.swf? Vid = 6851105. Copy the connection to the software input box and click Download.

 

Running Environment

1. Microsoft. NET Framework 2.0 you can find the download link from the download part of the article.

 

References

1. Download Sina flash method

2. c # read/write files (in various formats)

 

Body

1.

2. Procedure

2.1 right-click the page containing Sina video open source code, such as http://www.dapenti.com/blog/more.asp? Name = xilei & id = 18466 s. If it is blocked, you can consider changing the Opera and Chrome browsers.

2.2 search for the key word .swf, find the src attribute of the embed tag, and copy it to the software input box.

2.3 click Start download. Because some files are relatively large, the download time may exceed 30 seconds, but it does not matter. The Asynchronous Method is used here, you only need to minimize or click Close in the upper right corner to zoom in to the lower right corner to do your own thing :)

2.4 to exit the software, click the red exclamation point icon!

2.5 4-25 supplement, if it is similar to limit? Vid = 000089006-1234029735 to download, that is, the link before "vid =" is the same, and the value after the vid is the pseudo name of the page, that is, the 11689006-1234029735 here.

3. Some code

My friends who have read the image download tool should be familiar with this part of the code and download the accompanying source code.

Code snippet 1

// Download objects Asynchronously
HttpWebRequest hwr = WebRequest. Create (nUrl) as HttpWebRequest;
Hwr. AllowWriteStreamBuffering = false;
Hwr. AllowAutoRedirect = true;
// Hwr. ReadWriteTimeout = 5*1000; // The default timeout value is 5 minutes.
Hwr. BeginGetResponse (new AsyncCallback (AsyncDownLoadResult), hwr );

Code snippet 2

WebRequest request = (WebRequest) asyncResult. AsyncState;
String url = request. RequestUri. ToString ();
Try
{

WebResponse response = request. EndGetResponse (asyncResult );

If (response. ContentLength> 0)
{
If (! Directory. Exists (tbSavePath. Text. Trim ()))
Directory. CreateDirectory (tbSavePath. Text. Trim ());

Using (Stream stream = response. GetResponseStream ())
{
Using (FileStream fs = File. Create (Path. Combine (tbSavePath. Text. Trim (), Path. GetFileName (url ))))
{
Byte [] bytes = new byte [1, 10240];
Int n = 1;
While (n> 0)
{
N = stream. Read (bytes, 0, 10240 );
Fs. Write (bytes, 0, n );
}
}
}
}
}
Catch (Exception ex)
{
MessageBox. Show (ex. Message );
}

 

 

Download

1. exe files that can be directly run by the Sina Flash download tool. Net 2.0 is required.

2. Microsoft. NET Framework 2.0 runtime environment.

3. complete source code of Src.

Supplement

1. reprinted at least retain the source of the blog Park !!

2. do not blame my friends who are interested in my video surveillance series for not doing well. I am frustrated that the third part of the player's AVI file conversion has not been completed yet, so I plan to add two more summaries to end this series of articles. If the company's products sell well, I think I can spend more time to implement more functions. Of course, this series will also be released one after another. Thank you for your attention :)

 

End

The function is simple, but it is quite fun to write it by yourself. You can download one or more links on this page by adding a page address to the next edition. You are welcome to make suggestions and suggestions :)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.