Advertisement
Guest User

Untitled

a guest
Nov 8th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. string str = @"string WebsiteUrl = ""http://localhost:54361"";
  2. var configuration = Configuration.Default.WithDefaultLoader().WithCookies();
  3. var context = BrowsingContext.New(configuration);
  4. context.OpenAsync(WebsiteUrl).Wait();
  5.  
  6. var elem=context.Active.QuerySelector<IHtmlAnchorElement>(""a.log-in"");
  7. if (elem==null) return context.Active.Body.InnerHtml;
  8. elem.Navigate().Wait();
  9. context.Active.QuerySelector<IHtmlFormElement>(""form"").Submit(new
  10. {
  11. User = ""User"",
  12. Password = ""secret""
  13. }).Wait();
  14. context.Active.QuerySelector<IHtmlAnchorElement>(""a.secret-link"").Navigate().Wait();
  15.  
  16. return context.Active.QuerySelector(""p"").Text();
  17. ";
  18.  
  19. string ИмяФайлаСборки = typeof(MainWindow).Assembly.Location;
  20. string Каталог = System.IO.Path.GetDirectoryName(ИмяФайлаСборки);
  21.  
  22. var scr = Microsoft.CodeAnalysis.Scripting.ScriptOptions.Default
  23. .WithReferences(Каталог + @"AngleSharp.dll")
  24. // .WithReferences(typeof(Configuration).Assembly)
  25. .WithImports("System", "AngleSharp", "AngleSharp.Dom.Html", "AngleSharp.Extensions");
  26.  
  27. var result = Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScript.EvaluateAsync(str, scr).Result;
  28. textBoxEval.AppendText(result + Environment.NewLine);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement