Beispiel #1
0
        public async Task <List <string> > FindSearchResultForOneSearchWord(string searchWord)
        {
            Frame    frame = (Frame)Window.Current.Content;
            MainPage page  = (MainPage)frame.Content;

            var cts = new CancellationTokenSource();

            cts.CancelAfter(1000);

            HttpClient          http     = new System.Net.Http.HttpClient();
            HttpResponseMessage response = await http.GetAsync(@"https://itunes.apple.com/search?country=us&entity=software&limit=200&lang=en_us&term=" + searchWord, cts.Token);

            string HTMLFoundApps = await response.Content.ReadAsStringAsync();

            string[]      tokens   = HTMLFoundApps.Split();
            List <string> appParts = new List <string>();

            int start = 0;

            for (int i = 1; i < tokens.Length; i++)
            {
                if (tokens[i].Contains("artistViewUrl"))
                {
                    start = i;
                }
                if (tokens[i].Contains("\"userRatingCount\""))
                {
                    appParts.Add(string.Join(" ", SubArray(tokens, start, i)));
                    page.AppStoreUpdateDownloaded();
                    page.AppStoreUpdateTime();
                }
            }

            return(appParts);
        }