From cbee8b92bf83c318cba46cae53ce2b1aa52a8d5f Mon Sep 17 00:00:00 2001 From: mjjo Date: Wed, 15 Oct 2014 08:12:04 +0000 Subject: [PATCH] --- CyworldDownloader.csproj | 90 +++++++++++++++++++ CyworldDownloader.sln | 20 +++++ Form1.Designer.cs | 113 ++++++++++++++++++++++++ Form1.cs | 143 +++++++++++++++++++++++++++++++ Form1.resx | 120 ++++++++++++++++++++++++++ GDI32.cs | 34 ++++++++ Program.cs | 21 +++++ Properties/AssemblyInfo.cs | 36 ++++++++ Properties/Resources.Designer.cs | 71 +++++++++++++++ Properties/Resources.resx | 117 +++++++++++++++++++++++++ Properties/Settings.Designer.cs | 30 +++++++ Properties/Settings.settings | 7 ++ 12 files changed, 802 insertions(+) create mode 100644 CyworldDownloader.csproj create mode 100644 CyworldDownloader.sln create mode 100644 Form1.Designer.cs create mode 100644 Form1.cs create mode 100644 Form1.resx create mode 100644 GDI32.cs create mode 100644 Program.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 Properties/Settings.Designer.cs create mode 100644 Properties/Settings.settings diff --git a/CyworldDownloader.csproj b/CyworldDownloader.csproj new file mode 100644 index 0000000..4421285 --- /dev/null +++ b/CyworldDownloader.csproj @@ -0,0 +1,90 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {22CDA9BF-850D-4773-A260-B4C17D205B5A} + WinExe + Properties + CyworldDownloader + CyworldDownloader + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + Form + + + Form1.cs + + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/CyworldDownloader.sln b/CyworldDownloader.sln new file mode 100644 index 0000000..02616f2 --- /dev/null +++ b/CyworldDownloader.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CyworldDownloader", "CyworldDownloader.csproj", "{22CDA9BF-850D-4773-A260-B4C17D205B5A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {22CDA9BF-850D-4773-A260-B4C17D205B5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22CDA9BF-850D-4773-A260-B4C17D205B5A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {22CDA9BF-850D-4773-A260-B4C17D205B5A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {22CDA9BF-850D-4773-A260-B4C17D205B5A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Form1.Designer.cs b/Form1.Designer.cs new file mode 100644 index 0000000..58cebd5 --- /dev/null +++ b/Form1.Designer.cs @@ -0,0 +1,113 @@ +namespace CyworldDownloader +{ + partial class Form1 + { + /// + /// 필수 디자이너 변수입니다. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 사용 중인 모든 리소스를 정리합니다. + /// + /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form 디자이너에서 생성한 코드 + + /// + /// 디자이너 지원에 필요한 메서드입니다. + /// 이 메서드의 내용을 코드 편집기로 수정하지 마십시오. + /// + private void InitializeComponent() + { + this.wbLogin = new System.Windows.Forms.WebBrowser(); + this.wbContent = new System.Windows.Forms.WebBrowser(); + this.btDebug = new System.Windows.Forms.Button(); + this.wbPhoto = new System.Windows.Forms.WebBrowser(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // wbLogin + // + this.wbLogin.Location = new System.Drawing.Point(468, 12); + this.wbLogin.MinimumSize = new System.Drawing.Size(20, 20); + this.wbLogin.Name = "wbLogin"; + this.wbLogin.Size = new System.Drawing.Size(281, 132); + this.wbLogin.TabIndex = 0; + this.wbLogin.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.wbLogin_DocumentCompleted); + // + // wbContent + // + this.wbContent.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.wbContent.Location = new System.Drawing.Point(12, 12); + this.wbContent.MinimumSize = new System.Drawing.Size(20, 20); + this.wbContent.Name = "wbContent"; + this.wbContent.Size = new System.Drawing.Size(450, 519); + this.wbContent.TabIndex = 1; + this.wbContent.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.wbContent_DocumentCompleted); + // + // btDebug + // + this.btDebug.Location = new System.Drawing.Point(610, 184); + this.btDebug.Name = "btDebug"; + this.btDebug.Size = new System.Drawing.Size(75, 23); + this.btDebug.TabIndex = 2; + this.btDebug.Text = "break"; + this.btDebug.UseVisualStyleBackColor = true; + this.btDebug.Click += new System.EventHandler(this.btDebug_Click); + // + // wbPhoto + // + this.wbPhoto.Location = new System.Drawing.Point(468, 337); + this.wbPhoto.MinimumSize = new System.Drawing.Size(20, 20); + this.wbPhoto.Name = "wbPhoto"; + this.wbPhoto.Size = new System.Drawing.Size(279, 194); + this.wbPhoto.TabIndex = 3; + this.wbPhoto.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.wbPhoto_DocumentCompleted); + // + // pictureBox1 + // + this.pictureBox1.Location = new System.Drawing.Point(468, 240); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(279, 75); + this.pictureBox1.TabIndex = 4; + this.pictureBox1.TabStop = false; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(759, 543); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.wbPhoto); + this.Controls.Add(this.btDebug); + this.Controls.Add(this.wbContent); + this.Controls.Add(this.wbLogin); + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.WebBrowser wbLogin; + private System.Windows.Forms.WebBrowser wbContent; + private System.Windows.Forms.Button btDebug; + private System.Windows.Forms.WebBrowser wbPhoto; + private System.Windows.Forms.PictureBox pictureBox1; + } +} + diff --git a/Form1.cs b/Form1.cs new file mode 100644 index 0000000..895ce50 --- /dev/null +++ b/Form1.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.IO; + +namespace CyworldDownloader +{ + public partial class Form1 : Form + { + string strLoginURL = "http://www.cyworld.com"; + string strContentURL = "http://minihp.cyworld.com/pims/board/image/imgbrd_list.asp?tid=21572675&cpage=1"; + + bool m_bFirst = true; + + List photoURLlist = new List(); + + public Form1() + { + InitializeComponent(); + } + + private void Form1_Load(object sender, EventArgs e) + { + wbLogin.Navigate(strLoginURL); + } + + private void wbLogin_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) + { + WebBrowser browser = (WebBrowser)sender; + if(e.Url.Host != browser.Url.Host) + return; + + if(m_bFirst == true) + { + wbLogin.Document.GetElementById("ID").InnerText = "_last_@hanmail.net"; + wbLogin.Document.GetElementById("PASSDM").Focus(); + + wbLogin.Document.GetElementsByTagName("HTML")[0].ScrollTop = 201; + wbLogin.Document.GetElementsByTagName("HTML")[0].ScrollLeft = 652; + + m_bFirst = false; + } + else + { + photoURLlist.Clear(); + wbContent.Navigate(strContentURL); + } + } + + private void wbContent_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) + { + WebBrowser browser = (WebBrowser)sender; + if(e.Url.Host != browser.Url.Host) + return; + + HtmlElement element = browser.Document.GetElementsByTagName("BODY")[0]; + + //StreamWriter writer = new StreamWriter("content.html"); + //writer.Write(element.InnerHtml); + //writer.Close(); + + string strTarget = element.InnerHtml; + while(true) + { + int iPos = strTarget.IndexOf("file_down"); + if(iPos < 0) + break; + + int iPos2 = strTarget.Substring(Math.Max(iPos-200, 0), 200).LastIndexOf("http") + Math.Max(iPos-200, 0); + int iPos3 = strTarget.Substring(iPos2, 500).IndexOf("\"") + iPos2; + string photourl = strTarget.Substring(iPos2, iPos3-iPos2); + photoURLlist.Add(photourl); + Console.WriteLine(photourl); + + strTarget = strTarget.Substring(iPos3, strTarget.Length-iPos3); + } + + if(photoURLlist.Count > 0) + wbPhoto.Navigate(photoURLlist[0]); + } + + + + private void wbPhoto_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) + { + WebBrowser browser = (WebBrowser)sender; + if(e.Url.Host != browser.Url.Host) + return; + + + // 참고 + // http://www.developerfusion.com/code/4712/generate-an-image-of-a-web-page/ + + using (Graphics srcGraphics = browser.CreateGraphics()) + { + using (Graphics destGraphics = this.pictureBox1.CreateGraphics()) + { + IntPtr hdcDest = destGraphics.GetHdc(); + IntPtr hdcSrc = srcGraphics.GetHdc(); + GDI32.BitBlt( + hdcDest, + 0, 0, + browser.ClientRectangle.Width, browser.ClientRectangle.Height, + hdcSrc, + 0, 0, + (int) GDI32.SRCCOPY + ); + srcGraphics.ReleaseHdc(hdcSrc); + destGraphics.ReleaseHdc(hdcDest); + } + } + + //HtmlDocument dom = browser.Document; + + //htmlc + + //IHTMLDocument2 doc = (IHTMLDocument2)webBrowser1.Document.DomDocument; + //IHTMLControlRange imgRange = (IHTMLControlRange)((HTMLBody)doc.body).createControlRange(); + + //foreach(IHTMLImgElement img in doc.images) + //{ + // imgRange.add((IHTMLControlElement)img); + + // imgRange.execCommand("Copy", false, null); + + // using(Bitmap bmp = (Bitmap)Clipboard.GetDataObject().GetData(DataFormats.Bitmap)) + // { + // bmp.Save(@"C:\"+img.nameProp); + // } + //} + } + + private void btDebug_Click(object sender, EventArgs e) + { + Console.WriteLine("break"); + } + } +} diff --git a/Form1.resx b/Form1.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GDI32.cs b/GDI32.cs new file mode 100644 index 0000000..2a46765 --- /dev/null +++ b/GDI32.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace CyworldDownloader +{ + class GDI32 + { + public const int SRCCOPY = 0xCC0020; + + [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")] + public static extern int BitBlt( + IntPtr hdcDest, // handle to destination DC (device context) + int nXDest, // x-coord of destination upper-left corner + int nYDest, // y-coord of destination upper-left corner + int nWidth, // width of destination rectangle + int nHeight, // height of destination rectangle + IntPtr hdcSrc, // handle to source DC + int nXSrc, // x-coordinate of source upper-left corner + int nYSrc, // y-coordinate of source upper-left corner + int dwRop // raster operation code + ); + + [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")] + public static extern IntPtr CreateCompatibleDC(IntPtr hdc); + + [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")] + public static extern IntPtr SelectObject(IntPtr hdc, IntPtr obj); + + [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")] + public static extern void DeleteObject(IntPtr obj); + } +} diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..53f2e7a --- /dev/null +++ b/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace CyworldDownloader +{ + static class Program + { + /// + /// 해당 응용 프로그램의 주 진입점입니다. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c57106d --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("CyworldDownloader")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CyworldDownloader")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("94b142a9-8ed6-4444-bdc5-1edd2952e44a")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..f1d348c --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:2.0.50727.5477 +// +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. +// +//------------------------------------------------------------------------------ + +namespace CyworldDownloader.Properties +{ + + + /// + /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. + /// + // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder + // 클래스에서 자동으로 생성되었습니다. + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 + // ResGen을 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 이 클래스에서 사용한 캐시된 ResourceManager 인스턴스를 반환합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CyworldDownloader.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대한 현재 스레드의 CurrentUICulture + /// 속성을 재정의합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..d047a47 --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5477 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CyworldDownloader.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + +