It was very early to learn the data structure. The demo animation is collected. Help understanding. But not all. Read KMP todayAlgorithm. I saw a high-quality course from Fuzhou University .. 81 demo animations .. You want to package, download, and add to favorites. It is said that Fuzhou University is a good choice. Perform academic work in a down-to-earth manner.
The first method is manual .. Ga. Do you dare. Download one by one... Change names one by one ..
The second is the software downloaded from the entire site .. But I read the SWF name. I know that downloading is of little significance. Because the name is hard to understand.
The third is to write one by yourself.ProgramRight ..
The overall idea is to first access the course page, parse the title and content of each chapter, create a chapter folder, get the HTML page corresponding to each animation, and then parse the HTML page, extract the SWF address. Then download it.
The pain point is that the page uses gb2312 encoding. The parsing artifact htmlagilitypack cannot specify the encoding. You can only find a way to bypass it.
WebClient client =NewWebClient (); memorystream MS=NewMemorystream (client. downloaddata (URL); htmldocument Doc=NewHTML document (); Doc. Load (MS, encoding. getencoding ("Gb2312"));
The bypass method is to first use the built-in class to get the memory stream. Then load from the memory.
Then. The technology involved is XPath. See the XPath document. We have done a lot. Another thing in the middle is that I did not pay attention to it. This page has two files with the same name .. After debugging several times, you can find out ..
Using System; Using System. Collections. Generic; Using System. LINQ; Using System. text; Using Htmlagilitypack; Using System. IO; Using System. Threading; Using System. net; Namespace Fzuswf { Class Program { Static Void Main ( String [] ARGs) {dowork ();} // Execute task Static Void Dowork () {htmlweb Web = New Htmlweb (); htmldocument Doc = Web. Load ( " Http://ds.fzu.edu.cn/fine/resources/ " ); Htmlnode divresource = Doc. getelementbyid ( " Divresource " ); Foreach (Htmlnode child In Divresource. childnodes ){ If (Child. Name = " Table " ) {Htmlnode ptile = Child. selectsinglenode (" Tr [1] " ); Directory. createdirectory (ptile. innertext. Trim ()); Int I = 0 ; Htmlnodecollection pcontents = Child. selectnodes ( " Tr [position ()> 1] " ); Console. writeline (ptile. innertext. Trim ()); Foreach (Htmlnode oneIn Pcontents ){ String Link = one. selectsinglenode ( " ./TD [1]/P [1]/A [@ href] " ). Attributes [ " Href " ]. Value; Link = @" Http://ds.fzu.edu.cn/fine/resources/ " +Link; String Filename; filename = One. innertext. Trim (); If (One. innertext. Trim () = " Sequential storage representation of Binary Trees " ) {Filename + = I; I ++ ;} String Swflink = Getswfname (Link); console. writeline ( " -- " + Filename + Swflink); downswf (swflink, ptile. innertext. Trim () + @" / " + Filename + " . SWF " ); Thread. Sleep ( 1000 );}}}} // Download the specified SWF Static Void Downswf ( String URL, String Desname) {URI u = New Uri (URL); WebClient mywebclient = New WebClient (); mywebclient. downloadfileasync (u, desname );} // Obtains the SWF name of the specified page. Static String Getswfname ( String URL) {WebClient Client = New WebClient (); memorystream MS = New Memorystream (client. downloaddata (URL); htmldocument Doc = New HTML document (); Doc. Load (MS, encoding. getencoding ( " Gb2312 " ); Htmlnode HD = Doc. documentnode; String STR = HD. selectsinglenode ( " // A [@ href] " ). Attributes [ " Href " ]. Value; Return @" Http://ds.fzu.edu.cn/fine/resources/ " + STR ;}}}
Run after writing. Look at the following interface .. This is just to show me the progress. At the same time, the background is also being downloaded.
After running. The folder and file names are automatically named ..
: Package animation demo download
My blog: http://leaver.me