Example #1
0
        public static string GetStringValue(this HttpConnector.UserAgent userAgent)
        {
            if (userAgent == HttpConnector.UserAgent.Random)
            {
                userAgent = HttpConnector.GetRandomUserAgent();
            }
            switch (userAgent)
            {
            case HttpConnector.UserAgent.Mozilla:
                return("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2");

            case HttpConnector.UserAgent.Chrome:
                return("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36");

            case HttpConnector.UserAgent.Egde:
                return("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063");

            default:
                throw new NotImplementedException();
            }
        }
Example #2
0
        public async Task SendQueryAsync()
        {
            HttpConnector httpConnector = new HttpConnector();

            HttpConnector.UserAgent userAgent = HttpConnector.GetRandomUserAgent();
            DateTime date = GetRandomDateTime();
            Uri      uri  = new Uri("https://www.intercity.pl");

            Tuple <string, string> phpSessId = await httpConnector.GetResponseAsync(searchConnection.GetUri(), "", null, "", HttpConnector.HttpMethod.Get, userAgent);

            Console.Write("ICCFaker - Initialization done\n");

            Tuple <string, string> startStationIdresponse = await GetStationId(StartStation, phpSessId.Item2, uri, httpConnector, userAgent);

            string startStationId   = JsonSelector.GetFirstValueOfToken("h", startStationIdresponse.Item1);
            string startStationName = JsonSelector.GetFirstValueOfToken("n", startStationIdresponse.Item1).Replace(' ', '+');

            Console.Write("ICCFaker - Asked for station " + startStationName + "\n");
            Tuple <string, string> alertresult1 = await GetStationAlert(startStationId, date, startStationIdresponse.Item2, uri, httpConnector, userAgent);

            Console.Write("ICCFaker - Alerted station " + startStationName + "\n");

            Tuple <string, string> endStationIdresponse = await GetStationId(EndStarion, phpSessId.Item2, uri, httpConnector, userAgent);

            string endStationId   = JsonSelector.GetFirstValueOfToken("h", endStationIdresponse.Item1);
            string endStationName = JsonSelector.GetFirstValueOfToken("n", endStationIdresponse.Item1).Replace(' ', '+');

            Console.Write("ICCFaker - Asked for station " + endStationName + "\n");
            Tuple <string, string> alertresult2 = await GetStationAlert(endStationId, date, endStationIdresponse.Item2, uri, httpConnector, userAgent);

            Console.Write("ICCFaker - Alerted station " + endStationName + "\n");

            Tuple <string, string> searchResult = await GetSearchResult(startStationId, endStationId, startStationName, endStationName, date, endStationIdresponse.Item2, uri, httpConnector, userAgent);

            Console.Write("ICCFaker - Ended Search" + "\n");
        }