forked from hardkoded/puppeteer-sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DocFx implementation (hardkoded#318)
- Loading branch information
Showing
17 changed files
with
845 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
if($env:APPVEYOR_REPO_TAG -eq 'True' -And $env:framework -eq 'netcoreapp2.0') { | ||
git config --global credential.helper store | ||
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:git_access_token):x-oauth-basic@github.com`n" | ||
|
||
git config --global user.email "dariokondratiuk@gmail.com" | ||
git config --global user.name "Darío Kondratiuk" | ||
git remote add pages https://github.com/kblok/puppeteer-sharp.git | ||
git fetch pages | ||
git checkout master | ||
git subtree add --prefix docs pages/gh-pages | ||
docfx metadata docfx_project/docfx.json | ||
docfx build docfx_project/docfx.json -o docs | ||
git add docs/* -f | ||
git commit -m "Docs version $($env:APPVEYOR_REPO_TAG_NAME)" | ||
git subtree push --prefix docs pages gh-pages | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
############### | ||
# folder # | ||
############### | ||
/**/DROP/ | ||
/**/TEMP/ | ||
/**/packages/ | ||
/**/bin/ | ||
/**/obj/ | ||
_site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
############### | ||
# temp file # | ||
############### | ||
*.yml | ||
.manifest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# Puppeteer Sharp | ||
|
||
Puppeteer Sharp is a .NET port of the official [Node.JS Puppeteer API](https://github.com/GoogleChrome/puppeteer). | ||
|
||
# Usage | ||
|
||
## Take screenshots | ||
|
||
```cs | ||
await Downloader.CreateDefault().DownloadRevisionAsync(chromiumRevision); | ||
var browser = await Puppeteer.LaunchAsync(new LaunchOptions | ||
{ | ||
Headless = true | ||
}, chromiumRevision); | ||
var page = await browser.NewPageAsync(); | ||
await page.GoToAsync("http://www.google.com"); | ||
await page.ScreenshotAsync(outputFile); | ||
``` | ||
|
||
You can also change the view port before generating the screenshot | ||
|
||
|
||
```cs | ||
await page.SetViewport(new ViewPortOptions | ||
{ | ||
Width = 500, | ||
Height = 500 | ||
}); | ||
``` | ||
|
||
|
||
## Generate PDF files | ||
|
||
```cs | ||
await Downloader.CreateDefault().DownloadRevisionAsync(chromiumRevision); | ||
var browser = await Puppeteer.LaunchAsync(new LaunchOptions | ||
{ | ||
Headless = true | ||
}, chromiumRevision); | ||
var page = await browser.NewPageAsync(); | ||
await page.GoToAsync("http://www.google.com"); | ||
await page.PdfAsync(outputFile); | ||
``` | ||
|
||
## Inject HTML | ||
|
||
```cs | ||
using(var page = await Browser.NewPageAsync()) | ||
{ | ||
await page.SetContentAsync("<div>My Receipt</div>"); | ||
var result = await page.GetContentAsync(); | ||
await page.PdfAsync(outputFile); | ||
SaveHtmlToDB(result); | ||
} | ||
``` | ||
|
||
## Evaluate Javascript | ||
|
||
```cs | ||
using (var page = await Browser.NewPageAsync()) | ||
{ | ||
var seven = await page.EvaluateFunctionAsync<int>(“4 + 3”); | ||
var someObject = await page.EvaluateFunctionAsync<dynamic>("(value) => ({a: value})", 5); | ||
Console.WriteLine(someObject.a); | ||
} | ||
``` | ||
|
||
## Wait For Selector | ||
|
||
```cs | ||
using (var page = await Browser.NewPageAsync()) | ||
{ | ||
await page.GoToAsync("http://www.spapage.com"); | ||
await page.WaitForSelectorAsync("div.main-content") | ||
await page.PdfAsync(outputFile)); | ||
} | ||
``` | ||
|
||
## Wait For Function | ||
```cs | ||
using (var page = await Browser.NewPageAsync()) | ||
{ | ||
await page.GoToAsync("http://www.spapage.com"); | ||
var watchDog = page.WaitForFunctionAsync("window.innerWidth < 100"); | ||
await Page.SetViewport(new ViewPortOptions { Width = 50, Height = 50 }); | ||
await watchDog; | ||
} | ||
``` | ||
|
||
## Connect to a remote browser | ||
|
||
```cs | ||
var options = new ConnectOptions() | ||
{ | ||
BrowserWSEndpoint = $"wss://www.externalbrowser.io?token={apikey}" | ||
}; | ||
|
||
var url = "https://www.google.com/"; | ||
|
||
using (var browser = await PuppeteerSharp.Puppeteer.ConnectAsync(options)) | ||
{ | ||
using (var page = await browser.NewPageAsync()) | ||
{ | ||
await page.GoToAsync(url); | ||
await page.PdfAsync("wot.pdf"); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"metadata": [ | ||
{ | ||
"src": [ | ||
{ | ||
"cwd": "../", | ||
"files": [ | ||
"lib/PuppeteerSharp/**.csproj" | ||
] | ||
} | ||
], | ||
"dest": "api", | ||
"disableGitFeatures": false, | ||
"properties": { | ||
"TargetFramework": "net46" | ||
} | ||
} | ||
], | ||
"build": { | ||
"content": [ | ||
{ | ||
"files": [ | ||
"api/**.yml", | ||
"api/index.md" | ||
] | ||
}, | ||
{ | ||
"files": [ | ||
"toc.yml", | ||
"*.md" | ||
] | ||
} | ||
], | ||
"resource": [ | ||
{ | ||
"files": [ | ||
"images/**" | ||
] | ||
} | ||
], | ||
"overwrite": [ | ||
{ | ||
"files": [ | ||
"apidoc/**.md" | ||
], | ||
"exclude": [ | ||
"obj/**", | ||
"_site/**" | ||
] | ||
} | ||
], | ||
"dest": ".", | ||
"globalMetadataFiles": [], | ||
"fileMetadataFiles": [], | ||
"template": [ | ||
"default", | ||
"./template" | ||
], | ||
"postProcessors": [], | ||
"markdownEngineName": "markdig", | ||
"noLangKeyword": false, | ||
"keepFileLink": false, | ||
"cleanupCacheHistory": false, | ||
"disableGitFeatures": false | ||
} | ||
} |
Oops, something went wrong.