Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next page result parsing bug #12

Open
code-devy opened this issue Dec 19, 2024 · 1 comment
Open

Next page result parsing bug #12

code-devy opened this issue Dec 19, 2024 · 1 comment

Comments

@code-devy
Copy link

There may have been changes to the Microsoft Update Catalog page for parsing the next page since the first results page is returned. Adding an option to specify the page number in the search query (e.g. https://catalog.update.microsoft.com/Search.aspx?q=2024-11+Cumulative+Update&p=2) without it getting encoded q={UrlEncode(Query)}&p={PageNumber}) could work for parsing the next page for both SendSearchQueryAsync() and ParseNextPageAsync().

Example of pagination using ResultsCount and PageSize to determine NextPage:

            // TODO: Bug with catalogClient.ParseNextPageAync function,
            // which is also used by SendSearchQueryAsync(catalogQuery)
            
            // Work-around using GetFirstPageFromSearchQueryAsync to get first page of results
            
            int page = 1;
            int pageSize = 25;

            var currentResultsPage = await catalogClient.GetFirstPageFromSearchQueryAsync(catalogQuery);
            var allSearchResults = currentResultsPage.SearchResults;
            int totalCount = currentResultsPage.ResultsCount;
            var maxPages = (totalCount / pageSize) + (totalCount % pageSize == 0 ? 0 : 1);

            while (page < maxPages)
            {
                page++;
                // TODO: Bug with catalogClient.ParseNextPageAync function,
                // appears to parse currentPage instead of nextPage
                currentResultsPage = await catalogClient.ParseNextPageAsync(currentResultsPage);
                allSearchResults.AddRange(currentResultsPage.SearchResults);
            }
@Poushec
Copy link
Owner

Poushec commented Dec 19, 2024

Thanks, I'll take a look 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants