Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string str = @"string WebsiteUrl = ""http://localhost:54361"";
- var configuration = Configuration.Default.WithDefaultLoader().WithCookies();
- var context = BrowsingContext.New(configuration);
- context.OpenAsync(WebsiteUrl).Wait();
- var elem=context.Active.QuerySelector<IHtmlAnchorElement>(""a.log-in"");
- if (elem==null) return context.Active.Body.InnerHtml;
- elem.Navigate().Wait();
- context.Active.QuerySelector<IHtmlFormElement>(""form"").Submit(new
- {
- User = ""User"",
- Password = ""secret""
- }).Wait();
- context.Active.QuerySelector<IHtmlAnchorElement>(""a.secret-link"").Navigate().Wait();
- return context.Active.QuerySelector(""p"").Text();
- ";
- string ИмяФайлаСборки = typeof(MainWindow).Assembly.Location;
- string Каталог = System.IO.Path.GetDirectoryName(ИмяФайлаСборки);
- var scr = Microsoft.CodeAnalysis.Scripting.ScriptOptions.Default
- .WithReferences(Каталог + @"AngleSharp.dll")
- // .WithReferences(typeof(Configuration).Assembly)
- .WithImports("System", "AngleSharp", "AngleSharp.Dom.Html", "AngleSharp.Extensions");
- var result = Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScript.EvaluateAsync(str, scr).Result;
- textBoxEval.AppendText(result + Environment.NewLine);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement