C# Java 自动读取小说章节。

最近有人在帖子留言问如何获取小说章节,写篇文章说下吧。

上来先看下效果:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ZTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            foreach (string str in System.IO.File.ReadAllLines("d:\\xiaoshuo.txt", Encoding.Default))
            {
                //Console.WriteLine(str); // str就是每一行数据
                Print(str);
            }
        }
        private void Print(string str) {
            if (str.Contains("第") && str.Contains("章")) {
                Console.WriteLine(str); //
            }
        }
    }
}

写到这里可能有人说这也太简单了吧,的确。

如果有的需要负责章节读取的,欢迎留言。

猜你喜欢

转载自blog.csdn.net/u010919083/article/details/105312781