苏飞论坛

标题: 使用爬虫框架获取抖音主页数据的方法 [打印本页]

作者: 站长苏飞    时间: 2022-8-17 10:47
标题: 使用爬虫框架获取抖音主页数据的方法
[C#] 纯文本查看 复制代码
     string cookie =“这里大家随时自己复制一个Cookie即可,不需要用我的”;
            ////创建Httphelper对象
            HttpHelper http = new HttpHelper();
            //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
            //创建Httphelper参数对象
            HttpItem item = new HttpItem()
            {
                URL = "https://v.douyin.com/jyD2LqK",//URL     必需项
                Referer = "http://www.sufeinet.com/"
                ,Cookie= cookie
            };
            //请求的返回值对象
            HttpResult result = http.GetHtml(item);

            string sec_uid = Regex.Match(result.RedirectUrl, "sec_uid=([\\s\\S]*?)&").Groups[1].Value;

            string html = result.Html;


            item = new HttpItem()
            {
                URL = "https://www.douyin.com/user/" + sec_uid,//URL     必需项
                Referer = "http://www.sufeinet.com/",
                Cookie = cookie

            };
            //请求的返回值对象
            result = http.GetHtml(item);

            html = result.Html;


直找用上面代码即可获取抖音主页数据,
关于怎么分析,怎么获取Cookie这部分,大家可以自行发挥






欢迎光临 苏飞论坛 (http://www.sufeinet.com/) Powered by Discuz! X3.4