Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
“全民K歌” 歌曲下载链接解析
using System;
using System.Text.RegularExpressions;
using System.Net;
using System.Collections;
public Hashtable parseSong(string playPageUri)
const string REGEX_SHARE_URI = "^http:\\/\\/kg\\.qq\\.com\\/share\\.html\\?s=([0-9a-zA-z]+)$";
const string REGEX_PLAY_URI = "\"playurl\":\"(.*?)\"";
const string REGEX_SONG_NAME = "\"song_name\":\"(.*?)\"";
const string DETAIL_URI = "";
Match match = Regex.Match(playPageUri, REGEX_SHARE_URI);
if (!match.Success)
throw new FormatException("URI解析错误");
Hashtable ht = new Hashtable();
ht["shareId"] = match.Groups[1].Value;
string detailUri = DETAIL_URI + ht["shareId"];
var request = WebRequest.Create(detailUri) as HttpWebRequest;
using ( StreamReader reader = new StreamReader(request.GetResponseStream() ) )
string detail = reader.ReadToEnd();
Match m = Regex.Match(detail, REGEX_PLAY_URI);
if (!m.Success)
throw new FormatException("response解析错误");
ht["playurl"] = m.Groups[1].Value;
return ht;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.