不使用qvod播放器获取qvod播放路径的方法
程序员文章站
2024-02-24 22:33:34
复制代码 代码如下:static string gethtml(string url) ...
复制代码 代码如下:
static string gethtml(string url)
{
httpwebrequest request = webrequest.create(url) as httpwebrequest;
request.timeout = 16 * 1000;
httpwebresponse response = request.getresponse() as httpwebresponse;
stream stream = response.getresponsestream();
streamreader reader = new streamreader(stream, encoding.default);
string html = reader.readtoend();
stream.close();
return html;
}
static string filthtml(string htmlstr)
{
var jsurl = regex.match(htmlstr, "(?<=<script type=\"text/javascript\" src=\"/playdata/).*?(?=\"></script>)").value;
var title = regex.match(htmlstr, "(?<=<title>正在播放).*?(?=xxx</title>)").value;
var wildqvod = gethtml(string.format("http://xxx.com/playdata/{0}", jsurl));
var qvod = regex.match(wildqvod,@"(?<=\$).*?(?=\$)").value;
return string.format("{0}:{1}", title,qvod);
}
static void main(string[] args)
{
streamwriter sw = new streamwriter(@"d:\g.txt", true, encoding.unicode);
sw.autoflush = true;
var startnum = 787;
for (var i = 0; i < 3000; i++)
{
try
{
var starturl = string.format("http://xxx.com/player/index{0}-0-0.html", startnum + i);
var wildhtml = gethtml(starturl);
var onedata = filthtml(wildhtml);
onedata = string.format("{0}:{1}", startnum + i, onedata);
sw.writeline(onedata);
console.writeline(onedata);
system.threading.thread.sleep(2000);
}
catch
{
var onedata = string.format("{0}:出错了", i + startnum);
console.writeline(onedata);
sw.writeline(onedata);
}
}
sw.close();
console.readkey();
}