抖音C#版,自己抓第三方抖音网站
感谢http://dy.lujianqiang.com技术支持
文章更新:http://dy.lujianqiang.com这个服务器已经关了,现在没用了
版权归抖音公司所有,该博客只是为交流学习所使用,编译后的内容将24小时内删除
该程序所获取到的内容或视频归Beijing Microlive Vision Technology Co.Ltd公司所有
请浏览到该博客的人若已经编译成可执行文件,请将编译后的内容24小时内删除
若违反到法律,与本博客主Frank_dev无关
若侵犯到贵公司权益请联系我
邮箱:Frank_dev@qq.com
♥下面教如何实现这一功能
先打开vstudio 创建一个工程命名为Trill
namespace Trill { partial class Main_Window { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要修改 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main_Window)); this.video_player = new AxWMPLib.AxWindowsMediaPlayer(); this.Refresh = new System.Windows.Forms.Timer(this.components); this.last = new System.Windows.Forms.Button(); this.about = new System.Windows.Forms.Button(); this.message = new System.Windows.Forms.GroupBox(); this.icon = new System.Windows.Forms.PictureBox(); this.ID = new System.Windows.Forms.Label(); this.Message_Text = new System.Windows.Forms.Label(); this.Group = new System.Windows.Forms.GroupBox(); ((System.ComponentModel.ISupportInitialize)(this.video_player)).BeginInit(); this.message.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.icon)).BeginInit(); this.Group.SuspendLayout(); this.SuspendLayout(); // // video_player // this.video_player.Enabled = true; this.video_player.Location = new System.Drawing.Point(12, 12); this.video_player.Name = "video_player"; this.video_player.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("video_player.OcxState"))); this.video_player.Size = new System.Drawing.Size(232, 412); this.video_player.TabIndex = 4; // // Refresh // this.Refresh.Enabled = true; this.Refresh.Tick += new System.EventHandler(this.Refresh_Tick); // // last // this.last.Location = new System.Drawing.Point(260, 439); this.last.Name = "last"; this.last.Size = new System.Drawing.Size(186, 30); this.last.TabIndex = 1; this.last.Text = "下一个Video"; this.last.UseVisualStyleBackColor = true; this.last.Click += new System.EventHandler(this.last_Click); // // about // this.about.Location = new System.Drawing.Point(12, 439); this.about.Name = "about"; this.about.Size = new System.Drawing.Size(100, 30); this.about.TabIndex = 2; this.about.Text = "关于"; this.about.UseVisualStyleBackColor = true; this.about.Click += new System.EventHandler(this.about_Click); // // message // this.message.Controls.Add(this.icon); this.message.Controls.Add(this.ID); this.message.Location = new System.Drawing.Point(250, 12); this.message.Name = "message"; this.message.Size = new System.Drawing.Size(220, 97); this.message.TabIndex = 6; this.message.TabStop = false; this.message.Text = "作品信息:"; // // icon // this.icon.Location = new System.Drawing.Point(142, 20); this.icon.Name = "icon"; this.icon.Size = new System.Drawing.Size(52, 52); this.icon.TabIndex = 1; this.icon.TabStop = false; // // ID // this.ID.AutoSize = true; this.ID.Location = new System.Drawing.Point(6, 39); this.ID.Name = "ID"; this.ID.Size = new System.Drawing.Size(29, 12); this.ID.TabIndex = 0; this.ID.Text = "Data"; // // Message_Text // this.Message_Text.AutoSize = true; this.Message_Text.Location = new System.Drawing.Point(8, 19); this.Message_Text.Name = "Message_Text"; this.Message_Text.Size = new System.Drawing.Size(29, 12); this.Message_Text.TabIndex = 7; this.Message_Text.Text = "Text"; // // Group // this.Group.Controls.Add(this.Message_Text); this.Group.Location = new System.Drawing.Point(250, 121); this.Group.Name = "Group"; this.Group.Size = new System.Drawing.Size(220, 303); this.Group.TabIndex = 8; this.Group.TabStop = false; this.Group.Text = "评论"; // // Main_Window // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(482, 481); this.Controls.Add(this.Group); this.Controls.Add(this.message); this.Controls.Add(this.about); this.Controls.Add(this.video_player); this.Controls.Add(this.last); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.Name = "Main_Window"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Trill"; this.Load += new System.EventHandler(this.Main_Window_Load); ((System.ComponentModel.ISupportInitialize)(this.video_player)).EndInit(); this.message.ResumeLayout(false); this.message.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.icon)).EndInit(); this.Group.ResumeLayout(false); this.Group.PerformLayout(); this.ResumeLayout(false); } #endregion private AxWMPLib.AxWindowsMediaPlayer video_player; private System.Windows.Forms.Timer Refresh; private System.Windows.Forms.Button last; private System.Windows.Forms.Button about; private System.Windows.Forms.GroupBox message; private System.Windows.Forms.PictureBox icon; private System.Windows.Forms.Label ID; private System.Windows.Forms.Label Message_Text; private System.Windows.Forms.GroupBox Group; } }
@然后是C#代码:
using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Windows.Forms; namespace Trill { public partial class Main_Window : Form { public Main_Window() { InitializeComponent(); } private void Main_Window_Load(object sender, EventArgs e) { String video = "https://dy.lujianqiang.com/web"; //MessageBox.Show(video); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(video); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream ResStream = response.GetResponseStream(); Encoding encoding = Encoding.GetEncoding("utf-8"); StreamReader streamReader = new StreamReader(ResStream, encoding); var jObject = JObject.Parse(streamReader.ReadToEnd()); var nickname = jObject["nickname"].ToString(); nickname = nickname.Replace("\"", ""); ID.Text = "作者ID:" + nickname; var icon_address = jObject["avatar"].ToString(); icon_address = icon_address.Replace("\"", ""); //icon_address = icon_address.Replace("/", "\\"); //icon_address = icon_address.Replace("https", "http"); //MessageBox.Show(icon_address); icon.Image = Image.FromStream(System.Net.WebRequest.Create(icon_address).GetResponse().GetResponseStream()); var address = jObject["video"].ToString(); address = address.Replace("\"", ""); address = address.Replace("/", "\\"); address = address.Replace("https", "http"); video_player.URL = address; video_player.Ctlcontrols.play(); var comments = jObject["comments"].ToString(); comments = comments.Replace(",", ""); comments = comments.Replace("\"", ""); comments = comments.Replace("[", ""); comments = comments.Replace("]", ""); this.Message_Text.Text = comments; //MessageBox.Show(comments); } private void last_Click(object sender, EventArgs e) { String video = "https://dy.lujianqiang.com/web";//json in //MessageBox.Show(video); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(video); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream ResStream = response.GetResponseStream(); Encoding encoding = Encoding.GetEncoding("utf-8"); StreamReader streamReader = new StreamReader(ResStream, encoding); var jObject = JObject.Parse(streamReader.ReadToEnd()); var nickname = jObject["nickname"].ToString(); nickname = nickname.Replace("\"", ""); ID.Text = "作者ID:" + nickname; var icon_address = jObject["avatar"].ToString(); icon_address = icon_address.Replace("\"", ""); //icon_address = icon_address.Replace("/", "\\"); //icon_address = icon_address.Replace("https", "http"); //MessageBox.Show(icon_address); icon.Image = Image.FromStream(System.Net.WebRequest.Create(icon_address).GetResponse().GetResponseStream()); var address = jObject["video"].ToString();//json如何使用 address = address.Replace("\"", ""); address = address.Replace("/", "\\"); address = address.Replace("https", "http"); video_player.URL = address; video_player.Ctlcontrols.play(); var comments = jObject["comments"].ToString(); comments = comments.Replace(",", ""); comments = comments.Replace("[", ""); comments = comments.Replace("]", ""); comments = comments.Replace("\"", "");//转化符号 this.Message_Text.Text = comments; } private void previous_Click(object sender, EventArgs e) { } private void about_Click(object sender, EventArgs e) { MessageBox.Show("这是一个抖音第三方客户端...:]","About"); } private void Refresh_Tick(object sender, EventArgs e) { if (video_player.playState == WMPLib.WMPPlayState.wmppsStopped) { video_player.Ctlcontrols.play(); } } }
然后就完成啦,要完整源码的下方网站留言
------------------------------------转载请注明出处