프로그램/C# 2013. 3. 8. 02:07

C# 웹 검색

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//웹페이지 여는 함수
  private void OpenWebPage(string uri)
        {
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo.FileName = uri;
            process.Start();
        }
 
 
 
        private void Searchgo_Click(object sender, EventArgs e)
        {
            StringBuilder str = new StringBuilder();
            // Append로 지정된 문자열의 복사본을 이 인스턴스의 끝에 추가
            str.Append(textBox1.Text);
           
            if (comboBox1.SelectedIndex == 0)
            {
                // textBox에 글자가 입력이 안되었을때..
                if (textBox1.Text == "")
                    OpenWebPage("http://www.daum.net/");
                 
                else
                    OpenWebPage("http://search.daum.net/search?nil_suggest=btn&nil_ch=&rtupcoll=&w=tot&m=&lpp=&q=" + str.ToString());
            }
 
 
            if (comboBox1.SelectedIndex == 1)
            {
                // textBox에 글자가 입력이 안되었을때
                if (textBox1.Text == "")
                    OpenWebPage("http://www.naver.com/");
             
                else 
                    OpenWebPage("http://search.naver.com/search.naver?sm=tab_hty&where=nexearch&query=" + str.ToString() + "&lr=&aq=f");                   
            }
            if (comboBox1.SelectedIndex == 2)
            {
                // textBox에 글자가 입력이 안되었을때
                if (textBox1.Text == "")                   
                    OpenWebPage("http://www.google.co.kr/");
                 
                else
                    OpenWebPage("http://www.google.co.kr/search?complete=1&hl=ko&q=" + str.ToString());                   
            }
        }

'프로그램 > C#' 카테고리의 다른 글

C# 파일경로  (0) 2013.03.08
C# 메모리 줄이기, 메모리 강제회수  (0) 2013.03.08
C# 키 이벤트 ...  (0) 2013.03.08
C# try - catch 예외 처리  (0) 2013.03.08
C# 소스코드 작성법  (0) 2013.03.08