C# : 用程式下載一個網頁

作品

書籍

課程

程式集

小說集

論文集

散文集

影片集

編輯雜誌

程式人

電子書

JavaScript

計算語言學

微積分

Blender 動畫

C# 語言

系統程式

高等 C 語言

Java

Android

Verilog

Wikidot

R 統計軟體

機率統計

計算機數學

組合語言

人工智慧

開放原始碼

網路資源運用

計算機結構

相關訊息

常用工具

友站連結

在家教育

RSS

最新修改

網頁列表

簡體版

English

簡介

原始程式

using System;
using System.IO;
using System.Net;

class WebCrawler
{
    public static void Main(String[] args)
    {
        String text = fileToText(args[0]);
        String[] urls = text.Split('\n');
        for (int i = 0; i < urls.Length; i++)
        {
            Console.WriteLine(i + ":" + urls[i]);
            UrlToFile(urls[i], i+".htm");
        }
//        Console.WriteLine(text);
    }

    public static String fileToText(String filePath)
    {
        StreamReader file = new StreamReader(filePath);
        String text = file.ReadToEnd();
        file.Close();
        return text;
    }

    public static void UrlToFile(String url, String file) {
        WebClient webclient = new WebClient();
        webclient.DownloadFile("http://"+url, file);
    }
}

Facebook

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License