织梦如何做移动网站,药检局信息化网站系统建设方案,河北项目网,二手交易网站建设方案ppt1. 通过F12开发者工具#xff0c;下载音频文件
浏览器打开音频列表-F12快捷键-网络-媒体#xff0c;播放一个音频文件#xff0c;右边媒体下生成一个音频文件#xff0c;右击“在新标签页中打开”#xff0c;可以下载这个音频文件。 2.通过Fiddler Classic抓…1. 通过F12开发者工具下载音频文件
浏览器打开音频列表-F12快捷键-网络-媒体播放一个音频文件右边媒体下生成一个音频文件右击“在新标签页中打开”可以下载这个音频文件。 2.通过Fiddler Classic抓包工具批量下载音频资料
每播放一个音频文件页面就会向服务端发送一个get请求。浏览器打开get请求的URL地址可下载这个音频文件。 播放了多个音频文件页面发送多个get请求我们现在通过Fiddler Classic抓包工具获取这多个get请求的URL地址然后通过程序批量下载这些文件。 1) 下载Fiddler Classic工具下载地址Download Fiddler Web Debugging Tool for Free by Telerik
2开启接收https请求
Fiddler Classic默认不接收https请求需要开启一下。 Tools-Options-HTTPS 3点击左下角开启/关闭抓包。 显示“Capturing”为开启状态显示空白为关闭状态。 4点击“Remove all” 可清理抓取到的所有请求。 5Fiddler Classic开启抓包- 播放音频 Fiddler Classic抓取到音频播放的get请求其中“audio/mp4”格式的请求数据为想要获取到的url请求地址。 6将播放音频抓到的所有地址复制粘贴到excel表格中 7通过程序过滤出“audio/mp4”格式的请求并发送get请求自动下载音频文件。
下图是创建的winform界面 该界面的功能的实现
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Net.WebRequestMethods;namespace Test
{public partial class DownloadMP4 : Form{public DownloadMP4(){InitializeComponent();}private void Form2_Load(object sender, EventArgs e){tbxMP4.Text G:\\Downloads\\;}DataTable _dtExcel null;ListRespondModel _list new ListRespondModel();private void btnExcel_Click(object sender, EventArgs e){_dtExcel GetExcelData();}private void btnMP4_Click(object sender, EventArgs e){if (_dtExcel null) return;string httpUrl https://audiopay.cos.tx.xmcdn.com;if (_dtExcel.Rows?.Count 0){_list new ListRespondModel();foreach (DataRow dr in _dtExcel.Rows){if (dr[Content-Type].ToString().Contains(mp4)){if (_list.FindIndex(p p.URL.Split(?).First().Split(/).Last() dr[URL].ToString().Split(?).First().Split(/).Last()) 0){RespondModel mod new RespondModel();mod.URL httpUrl dr[URL].ToString();//mod.ContentType audio/mp4;_list.Add(mod);}}}}int i 0;if (_list.Count 0) {foreach (RespondModel resp in _list) {string fileName tbxMP4.Text DateTime.Now.ToString(yyyyMMddHHmmssfff) .mp4;GetPostContent(resp.URL, fileName);i 1;progressBar1.Value i * 100 / _list.Count;}}MessageBox.Show($下载完成文件数{i});}private DataTable GetExcelData(){OpenFileDialog ofd new OpenFileDialog();ofd.Title 选择Excel文件;ofd.InitialDirectory System.Windows.Forms.Application.StartupPath \\;ofd.Filter Excel文件 (*.xlsx)|*.xlsx|Excel文件 (*.xls)|*.xls|所有文件 (*.*)|*.*;ofd.RestoreDirectory true;if (ofd.ShowDialog() DialogResult.OK){string fileName ofd.FileName;tbxExcel.Text fileName;string connectionString $Provider Microsoft.Jet.OLEDB.4.0 ; Data Source {fileName};Extended PropertiesExcel 8.0;if (fileName.Contains(xlsx)){connectionString $ProviderMicrosoft.Ace.OleDb.12.0; Data Source {fileName};Extended PropertiesExcel 12.0;}OleDbConnection conn new OleDbConnection(connectionString);conn.Open();DataTable dtNames conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, TABLE });string sql $select * from [{dtNames.Rows[0][TABLE_NAME]}]; //[Sheet1$]OleDbDataAdapter adapter new OleDbDataAdapter(sql, conn);DataSet ds new DataSet();adapter.Fill(ds);conn.Close();return ds?.Tables[0];}return null;}private HttpClient _httpClient;public void GetPostContent(string url, string localSavePath){try{ServicePointManager.SecurityProtocol SecurityProtocolType.Tls12;HttpWebRequest myRequest (HttpWebRequest)WebRequest.Create(url);myRequest.Method GET;myRequest.ContentType application/x-www-form-urlencoded;myRequest.Proxy null;// Get responseHttpWebResponse myResponse (HttpWebResponse)myRequest.GetResponse();Stream responseStream myResponse.GetResponseStream();Stream stream new FileStream(localSavePath, FileMode.Create);byte[] bArr new byte[1024];int size responseStream.Read(bArr, 0, (int)bArr.Length);while (size 0){stream.Write(bArr, 0, size);size responseStream.Read(bArr, 0, (int)bArr.Length);}stream.Close();responseStream.Close();}catch (System.Exception ex){throw ex;}}}public class RespondModel{public string URL { get; set; }public string ContentType { get; set; }}
}