Skip to content

Commit 1b818fb

Browse files
committed
Updated documentation
1 parent dcdf152 commit 1b818fb

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ AngleSharp.Io extends AngleSharp with powerful requesters, caching mechanisms, a
1414

1515
## Basic Configuration
1616

17+
### Requesters
18+
1719
If you just want to use *all* available requesters provided by AngleSharp.Io you can do the following:
1820

1921
```cs
@@ -24,6 +26,64 @@ var config = Configuration.Default
2426

2527
This will register all requesters. Alternatively, the requesters can be provided explicitly. They are located in the `AngleSharp.Io.Network` namespace and have names such as `DataRequester`.
2628

29+
### Cookies
30+
31+
To get improved cookie support, e.g., do
32+
33+
```cs
34+
var config = Configuration.Default
35+
.WithTemporaryCookies(); // Uses memory cookies
36+
```
37+
38+
or if you want to have persistent cookies you can use:
39+
40+
```cs
41+
var syncPath = $"Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)\\anglesharp.cookies";
42+
var config = Configuration.Default
43+
.WithPersistentCookies(syncPath); // Uses sync cookies against the given path
44+
```
45+
46+
Alternatively, the new overloads for the `WithCookies` extension method can be used.
47+
48+
### Downloads
49+
50+
AngleSharp.Io offers you the possibility of a simplified downloading experience. Just use `WithStandardDownload` to redirect resources to a callback.
51+
52+
In the simplest case you can write:
53+
54+
```cs
55+
var config = Configuration.Default
56+
.WithStandardDownload((fileName, content) =>
57+
{
58+
// store fileName with the content stream ...
59+
});
60+
```
61+
62+
Alternatively, use `WithDownload`, which allows you to distinguish also on the provided MIME type.
63+
64+
## DOM Extension Methods
65+
66+
The `IHtmlInputElement` interface now has `AppendFile` to easily allow appending files without much trouble.
67+
68+
```cs
69+
document
70+
.QuerySelector<IHtmlInputElement>("input[type=file]")
71+
.AppendFile("c:\\example.jpg");
72+
```
73+
74+
More overloads exist.
75+
76+
Furthermore, the `IUrlUtilities` interface now has `DownloadAsync`.
77+
78+
```cs
79+
document
80+
.QuerySelector<IHtmlAnchorElement>("a#download-document")
81+
.DownloadAsync()
82+
.SaveToAsync("c:\\example.pdf");
83+
```
84+
85+
The `SaveToAsync` (as well as the `CopyToAsync`) are extension methods for the `IResponse` interface.
86+
2787
## Features
2888

2989
- New requesters
@@ -34,6 +94,8 @@ This will register all requesters. Alternatively, the requesters can be provided
3494
- Enhanced support for about: URLs
3595
- WebSockets (mostly interesting for scripting engines, e.g., JS)
3696
- Storage support by providing the `IStorage` interface
97+
- Improved cookie container (`AdvancedCookieContainer`)
98+
- Enhanced download capabilities for resources / links
3799

38100
## Participating
39101

0 commit comments

Comments
 (0)