. Net to parse the real video download addresses of Major video websites nationwide

Source: Internet
Author: User
This is a software developed a year ago. It is mainly used to analyze the real videos of Major video websites. Of course, it is not implemented by me. I called shuomu for implementation.
Video Information Analysis class:
Using system; using system. collections. generic; using system. LINQ; using system. text; using system. windows. forms; using system. net;/** video analysis * call the data on the official website of shuomu for analysis and processing */namespace websitevideo {public class videoanalysis {public videoanalysis () {// instantiate the video information object videoinfo = new videoinfo ();} private Void analysis (string URL) {// record start time dt1 = datetime. now; try {WebClient mywebclient = new WebClient (); mywebclient. Credentials = credentialcache. defaultcredentials; // gets or sets the network credenbybyte [] pagedata = mywebclient. downloaddata ("http://www.flvcd.com/parse.php? Format = & kW = "+ URL); // download data from the specified website string pagehtml = encoding. default. getstring (pagedata); // If gb2312 is used to retrieve the website page, use this sentence // determine whether the resolution is successful if (pagehtml. indexof ("the expected result is not found")> 0 | pagehtml. indexof ("flvcd does not support resolution of this address currently")> 0) {state = false; return;} // If (pagehtml. indexof ("<input type = \" Hidden \ "name = \" INF \ "value = \" ") <0) {state = false; return ;} // extract data int star = pagehtml. indexof ("<input type = \" Hidd En \ "name = \" INF \ "value = \""); int c = "<input type = \" Hidden \ "name = \" INF \ "value = \"". length; int end = pagehtml. indexof ("\"/> ", star + C); string data = pagehtml. substring (Star + C, end-(Star + C); // data segmentation string [] TMP = data. split ('\ n'); videoinfo. files. addrange (TMP); // Title extraction try {string T1 = "<input type = \" Hidden \ "name = \" FILENAME \ "value = \""; string t2 = "\"/> "; star = pagehtml. indexof (T1) + t1.length; end = pagehtml. indexof (t2, Star); String title = pagehtml. substring (Star, end-star); videoinfo. title = title;} catch {videoinfo. title = "unknown";} // empty data list <string> List = new list <string> (); foreach (string s in videoinfo. files) {If (s! = String. empty) list. add (s);} videoinfo. files = List; // mark as successful state = true; dt2 = datetime. now;} catch (exception e) {dt2 = datetime. now; throw new exception (E. message) ;}} public void go (string URL) {analysis (URL) ;}// status public bool state {set; get ;}public int progress {set; get ;} public videoinfo {set; get;} // record the resolution time // start time, end time datetime dt1, dt2; public String subdatetime {get {// obtain the time difference timespan ts1 = new timespan (dt1.ticks); timespan ts2 = new timespan (dt2.ticks); timespan Ts = ts1.subtract (ts2 ). duration (); Return ts. milliseconds. tostring ();}}}}

Video Information:

Using system; using system. collections. generic; using system. LINQ; using system. text;/** video file information */namespace websitevideo {public class videoinfo {public videoinfo () {files = new list <string> ();} /// <summary> /// title /// </Summary> Public String title {set; get ;} /// <summary> /// format /// </Summary> Public string type {get {// analysis Format String [] TMP = title. split ('. '); If (TMP. length> = 2) {string type = TMP [TMP. length-1]; return type;} return "" ;}} public int count {get {return files. count ;}//< summary> /// address list /// </Summary> public list <string> files {set; get ;}}}

Note: For reprint, enter the original article address panjing.

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.