The whole workflow. It opens a page, records what that page asked the network for, and prints the calls worth calling yourself. Each piece is broken down below.
using System;
using System
using GenerallyPositive;
using GenerallyPositive
using static GenerallyPositive
GPAL
IBrowser browser = GPAL
browser
foreach (GPALCall call in calls)
GPAL
$"[{call
browser
CaptureCalls turns recording on, and from that point every request the browser makes is kept: method, url, resource type, status, headers and body. Nothing before the call is recorded, so it belongs ahead of the GoTo that triggers the traffic you want. Pass false to stop.
browser
Puppeteer reports requests over CDP, OttoMagic watches with the extension's webRequest listener, and Selenium records them in the page through the driver. All three can capture. A browser with none of those available says so once rather than quietly recording nothing.
A modern page asks for three hundred things and three of them matter. WithCallFilter keeps only the calls whose url contains the fragment you give it, so the list you read back is the endpoint rather than the fonts, images and analytics around it. Say it before capturing.
browser
Nothing is missed by declaring the filter late, only unrecorded. Traffic that went past before capturing started was never kept, and no filter brings it back.
The out overload hands back everything recorded so far, as a list of GPALCall. Url, Method, ResourceType, Status, Initiator and PostData are all there, and Headers holds what the page's own code added, which is the part a request built by hand always leaves out. Status is what the page itself got, so it separates an endpoint worth calling from one the page is failing at too.
browser
foreach (GPALCall call in calls)
{
GPAL
foreach (KeyValuePair<string, string> header in call
GPAL
}
Calling CaptureCalls again keeps recording on for any tab opened since, and hands back everything since the browser started. A long-running spy can poll it on a timer without losing anything.
Reading the list tells you what the endpoint is. CaptureCallTemplate goes one step further and hands the call back as a GPALRequest, ready to issue: the path, the method, the body and the headers the page's own code added. That is how a workflow carries a value it cannot know, a token minted per session or a signed parameter, because the template comes from the run that is happening rather than from something pasted in last week.
browser
if (null == priceFrom)
GPAL
CaptureCallTemplate blocks until a matching call arrives or it runs out of time, and the last match wins, since a page that calls an endpoint more than once has settled by the last one. When nothing matched it hands back null rather than throwing, so the workflow decides what that means. Check for null before using it.
A template on its own is a description. Give it to .Fetch and the page issues it again, carrying the session it already earned. That is the next tutorial in this section.
browser
Showing off some plain text in these paragraphs eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Here you can find different accents and emphasis sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
This is a link and how it could look like bestlinkinthebeautifulworld. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Here's just some classic bold text adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam notBoldSecondbestlinkinthebeautifulworld illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Obcaecati, iste distinctio veritatis eligendi laboriosam adipisicing elit illo nostrum corporis at adipisicing elit libero vel voluptas? Expedita, adipisicing facere dolores voluptatem ad ab rem assumenda soluta!
Other cuple of colors in case we want to emphasize several ways adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam adipisicing elit illo nostrum corporis at voluptatem libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta! Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quod veniam, quam ad expedita laborum sed at voluptates culpa ipsam ut vel. Ullam temporibus a mollitia quod aliquam ratione exercitationem nesciunt.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta! Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quod veniam, quam ad expedita laborum sed at voluptates culpa ipsam ut vel. Ullam temporibus a mollitia quod aliquam ratione exercitationem nesciunt.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae quas consequuntur illo numquam assumenda autem exercitationem distinctio perspiciatis in natus. Eius dicta similique ipsam ipsa minima, nemo quae enim tempore.
GPAL
.CallIfNotFound(GenericCallIfNotFound)
.WithPublishToConsole();
//System.Drawing.Rectangle windowSize = new System.Drawing.Rectangle(10, 10, 1500, 1024);
// NOTE: we have to set browser = before we execute any steps
// this is due to the 'GenericCallIfNotFound' which might throw an exception, and BankScraper will not have the browser set when it calls scraper.Close()
// until the complete fluent line gets executed (meaning every step, meaning browser is not set until everything else succeeds)
browser = GPAL.Browser
.WithBrowserType(Enums.BrowserType.Chrome)
.WithProfileDataDirectory(ChromeProfileLocation)
.WithUseAutomationEngine(AutomationEngine.Selenium)
.WithWindowSize(new System.Drawing.Rectangle(0,0,1920,1080))
.ToGPALObject();