コード例 #1
0
ファイル: Form1.cs プロジェクト: pyupyui/tfcmp_yvun
        void yvun_main()
        {
            webBrowser1.Navigate("https://www.youtube.com/channel/UCTSaxXnhUcrhv984bVpDr6Q/videos");

            while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }

            string video_data_raw = Regex.Match(webBrowser1.DocumentText, "(?<=<h3 class=\"yt-lockup-title \">)(.*?)(?=</span></h3>)", RegexOptions.Singleline).Value;
            string link           = Regex.Match(video_data_raw, "(?<=href=\"/watch\\?v\\=)(.*?)(?=\")").Value;
            string title          = Regex.Match(video_data_raw, "(?<=rel=\"nofollow\">)(.*?)(?=</a>)").Value;

            Video_Data    web_video_data            = new Video_Data(link, title);
            string        file_video_data_link      = File.ReadAllText("video_link.txt");
            List <string> file_video_data_link_list = new List <string>(Regex.Split(file_video_data_link, "\r\n"));

            if (file_video_data_link_list.Contains(web_video_data.link) == false)
            {
                upload_cafe_article(web_video_data);
                File.AppendAllText("video_link.txt", "\r\n" + web_video_data.link);
            }
            else
            {
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: pyupyui/tfcmp_yvun
        void upload_cafe_article(Video_Data video_data)
        {
            //mobile naver cafe write page
            webBrowser1.Navigate("https://m.cafe.naver.com/ArticleWrite.nhn?m=write&clubid=29846417&menuid=");

            while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }

            //article category select //selectedIndex = 4
            webBrowser1.Document.GetElementsByTagName("select")[0].SetAttribute("selectedIndex", "4");
            webBrowser1.Document.GetElementById("subject").SetAttribute("value", "[유튜브 영상] " + video_data.title);

            webBrowser1.Document.Window.Frames["frame"].Document.Body.InnerHtml =
                "<iframe width=\"560\" height=\"315\" src=\"" +
                "https://www.youtube.com/embed/" + video_data.link +
                "\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>";

            HtmlElementCollection hec = webBrowser1.Document.GetElementsByTagName("a");

            foreach (HtmlElement a in hec)
            {
                if (a.InnerText == "등록")
                {
                    a.InvokeMember("click");
                    break;
                }
            }
        }