Resource

ÀÌ ÆäÀÌÁö´Â ÇѾç´ëÇб³ ÃÖÁ߹Π±³¼ö²²¼­ ÀÛ¼ºÇÑ °ÍÀÔ´Ï´Ù.


[¿Â¶óÀÎ HTML ¹®¼­ fetch ¹æ¹ý]

(1) Java ¾ð¾î¸¦ ÀÌ¿ëÇÏ´Â °æ¿ì, (2) Unix¿¡¼­ C (C++)À» ÀÌ¿ëÇÏ´Â °æ¿ì, ±×¸®°í (3) Windows (95 or NT)¿¡¼­ C (C++)À» ÀÌ¿ëÇÏ´Â °æ¿ì·Î ³ª´©¾î¼­ ¼³¸íÇÑ´Ù.

ºÒÇàÈ÷µµ, ´Ù¸¥ ¾ð¾îÀÏ °æ¿ì´Â ³» ¼öÁØ¿¡¼­´Â ´ëÃ¥¾øÀ½.

  1. Java¸¦ ÀÌ¿ëÇÏ´Â °æ¿ì

    JDKÀÇ java.net package¿¡¼­ Á¦°øµÇ´Â URLÀ̶ó´Â type°ú java.io package¿¡¼­ Á¦°øµÇ´Â openStream, DataInputStream µîÀÇ method¸¦ È°¿ëÇÏ¸é µÈ´Ù.

    °£´ÜÇÑ sample program (URLOpen.java)Àº ´ÙÀ½°ú °°´Ù. ÀÌ ÇÁ·Î±×·¥Àº ¾ßÈÄ (Yahoo) °Ë»ö¿£ÁøÀÇ URLÀ» ÁÖ°í ÇØ´ç Ȩ ÆäÀÌÁöÀÇ HTML ¼Ò½º¸¦ Çѹø¿¡ ÇÑ ÁÙ¾¿ °¡Á®¿Í¼­ È­¸é¿¡ Ãâ·Â½ÃÄÑÁÖ°Ô µÈ´Ù.

    import java.net.*;
    import java.io.*;
    
    class URLOpen {
        public static void main(String[] args) {
            try {
                URL yahoo = new URL("http://www.yahoo.com/");
                DataInputStream dis = new DataInputStream(yahoo.openStream());
                String inputLine;
                 while ((inputLine = dis.readLine()) != null) {
                    System.out.println(inputLine);
                }
                dis.close();
            } catch (MalformedURLException me) {
                System.out.println("MalformedURLException: " + me);
            } catch (IOException ioe) {
                System.out.println("IOException: " + ioe);
            }
        }
    }
    

    ¸¸ÀÏ HTML source¸¦ È­ÀÏ¿¡ ÀúÀåÇÏ·Á¸é Java¿¡¼­ Á¦°øÇÏ´Â output stream¿¡ ´ëÇÑ method¸¦ ÀÌ¿ëÇÏ¸é µÉ °ÍÀÌ´Ù.

  2. Unix¿¡¼­ C (¶Ç´Â C++)¸¦ ÀÌ¿ëÇÏ´Â °æ¿ì

  3. Windows (95 or NT)¿¡¼­ C (¶Ç´Â C++)¸¦ ÀÌ¿ëÇÏ´Â °æ¿ì