示例#1
0
        static void Main(string[] args)
        {
            //html agile config
            HtmlWeb htmlWeb = new HtmlWeb()
            {
                AutoDetectEncoding = false,
                OverrideEncoding   = Encoding.GetEncoding("iso-8859-2")
            };
            //read html page
            HtmlDocument           htmlDocument = htmlWeb.Load("http://www.mzkb-b.internetdsl.pl/linie_r.htm#1");
            IEnumerable <HtmlNode> table        = htmlDocument.DocumentNode.SelectNodes("//table").Descendants("tr");

            List <BusLink>     busLinkList    = new List <BusLink>();
            List <BusStopLink> busStopLink    = new List <BusStopLink>();
            List <string>      processedLinks = new List <string>();

            //extract content from main page
            MainPage          mainPage          = new MainPage();
            BusLinksExtractor busLinksExtractor = new BusLinksExtractor(mainPage, table, busLinkList);

            //Extract time tables from MZK Bielsko website
            TimeTableParser    timeTableParser    = new TimeTableParser();
            TimeTableExtractor timeTableExtractor = new TimeTableExtractor(timeTableParser, busStopLink, busLinkList, htmlWeb, processedLinks);

            //Extract busStops for Neo4j graph database
            BusStopsParser    busStopsParser    = new BusStopsParser();
            BusStopsExtractor busStopsExtractor = new BusStopsExtractor(busStopsParser, busStopLink, busLinkList, htmlWeb, processedLinks);
        }
示例#2
0
文件: Program.cs 项目: MeilCli/Tbus
        static async Task Main(string[] args)
        {
            string applicationDirectory = AppDomain.CurrentDomain.BaseDirectory;
            int    index        = applicationDirectory.IndexOf("\\Tbus.Parser.NETCore.Console");
            string solutionPath = applicationDirectory.Substring(0, index);

            WriteLine($"solution path: {solutionPath}");
            var outputDirectory = Directory.CreateDirectory($"{solutionPath}/docs/timetable");

            foreach (var deleteFile in outputDirectory.EnumerateFiles())
            {
                deleteFile.Delete();
            }
            WriteLine($"output path: {outputDirectory.FullName}");

            var timeTableParser = new TimeTableParser();

            foreach (var data in createTimeTableDataList())
            {
                int number = 1;
                foreach (var t in data.timeTableData)
                {
                    TimeTable timeTable = await timeTableParser.ParseUrlAsync(t.Url, data.id, t.LimitedTimeOption);

                    if (t.LimitedTimeOption == null)
                    {
                        // default
                        output(timeTable, outputDirectory, $"{data.fileNameWithoutExtension}.json");
                    }
                    else
                    {
                        output(timeTable, outputDirectory, $"{data.fileNameWithoutExtension}.limited{number}.json");
                        number++;
                    }
                }
            }

            WriteLine("finish");
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Wybierz opcję:");
            Console.WriteLine("1. Rozkład jazdy - utworzenie nowego pliku timeTable.json");
            Console.WriteLine("2. Pliki CSV do konfiguracji grafowej bazy danych (Neo4j)");
            string input = Console.ReadLine();

            //html agile config
            HtmlWeb htmlWeb = new HtmlWeb()
            {
                AutoDetectEncoding = false,
                OverrideEncoding   = Encoding.GetEncoding("iso-8859-2")
            };
            //read html page
            HtmlDocument           htmlDocument = htmlWeb.Load("http://www.mzkb-b.internetdsl.pl/linie_r.htm#1");
            IEnumerable <HtmlNode> table        = htmlDocument.DocumentNode.SelectNodes("//table").Descendants("tr");

            List <BusLink>     busLinkList    = new List <BusLink>();
            List <BusStopLink> busStopLink    = new List <BusStopLink>();
            List <string>      processedLinks = new List <string>();

            //extract content from main page
            MainPage          mainPage          = new MainPage();
            BusLinksExtractor busLinksExtractor = new BusLinksExtractor(mainPage, table, busLinkList);

            if (input == "1")
            {
                //Extract time tables from MZK Bielsko website
                TimeTableParser    timeTableParser    = new TimeTableParser();
                TimeTableExtractor timeTableExtractor = new TimeTableExtractor(timeTableParser, busStopLink, busLinkList, htmlWeb, processedLinks);
            }
            else if (input == "2")
            {
                //Extract busStops for Neo4j graph database
                BusStopsParser    busStopsParser    = new BusStopsParser();
                BusStopsExtractor busStopsExtractor = new BusStopsExtractor(busStopsParser, busStopLink, busLinkList, htmlWeb, processedLinks);
            }
        }