본문 바로가기
카테고리 없음

웹사이트 내용 및 제목 얻는 방법

by 호야호잇 2020. 4. 2.

내용을 얻는 간단한 방법 :

WebClient x = new WebClient(); string source = x.DownloadString("http://www.singingeels.com/"); Dim x As WebClient = New WebClient()
    Dim source As String = x.DownloadString("http://www.singingeels.com/")

 

제목을 얻는 더 간단하고 안정적인 방법 :

string title = Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value;Dim title As String = Regex.Match(source, "\<title\b[^>]*\>\s*(?", RegexOptions.IgnoreCase).Groups("Title").Value