2011-09-21 3 views
1

예를 들어 웹 페이지가 있습니다 (http://guyism.com/humor/mathematical-equations-that-explain-men.htm l). HttpWebRequest을 사용하면 웹 페이지의 스트림을 가져올 수 있습니다. 이제 아래 그림과 같이 브라우저에 콘텐츠 (이미지 참조)를 표시하고 싶습니다. 어떻게 이것을 달성 할 수 있습니다.읽을 수있는 형식으로 웹 페이지의 텍스트를 저장하는 방법

enter image description here

+0

의 조회를 할 수 있도록 당신의 서버에, guyism.com의 구조에이 페이지에 따라 달라집니다, 또는 콘텐츠 당신을 표시하려고 통제하지 않습니까? 그것은 접근 방식에 차이를 만들 수 있습니다. – wllmsaccnt

+0

HttpWebRequest를 사용하여 원격 페이지 스트림을받는 방식을 보여줄 수 있습니까? 단순히 페이지의 div 안에 해당 내용을 렌더링하고 싶습니까? –

+0

또한 액세스하려는 페이지는 로그인해야합니까? – wllmsaccnt

답변

0

은 iframe을 사용하면 당신이 찾고있는 무엇에 따라 문제에 대한 하나의 해결책이 될 수 있습니다. 당신이 페이지를 움켜 쥐고 그것들을 내뱉고 싶다면 cURL을 사용하는 것입니다. 유사한 기능을 제공 할 수도 있습니다. 거기에 몇 가지 웹 프록시가 내장되어 있습니다. 두 가지에 대한 정보가 있습니다.

iframe을 :

http://www.iframehtml.com/

말림 :이 방법에 대해 http://curl.haxx.se/libcurl/dotnet/

0

닷넷 에 대한 http://curl.haxx.se/libcurl/c/example.html

컬, WebBrowser 컨트롤을 사용하여. 그러나 임의의 페이지에 당신이 컨테이너 div (??)

 void Load() 
     { 
      string html = DownloadHtml("http://guyism.com/humor/mathematical-equations-that-explain-men.html"); 

      MatchCollection matches = Regex.Matches(html, @"(<div class=""blog-post-inside"">.*?<center>---</center>)", RegexOptions.Singleline);  

      webBrowser.ScriptErrorsSuppressed = true; 

      webBrowser.DocumentText = matches[ 0 ].Groups[ 1 ].Value; 
     } 

     string DownloadHtml(string url) 
     { 
      using (var client = new WebClient()) 
      { 
       using (var reader = new StreamReader(client.OpenRead(url))) 
       { 
        return reader.ReadToEnd(); 
       } 
      } 
     } 
관련 문제