37 lines
610 B
Markdown
37 lines
610 B
Markdown
|
# puppeteer api client
|
||
|
|
||
|
This is a golang client for the api exposed by the puppeteer docker container.
|
||
|
|
||
|
https://github.com/l0co/docker-puppeteer-api
|
||
|
|
||
|
# usage
|
||
|
|
||
|
```go
|
||
|
package main
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
func main() {
|
||
|
apiURL := os.Getenv("API_URL")
|
||
|
apiSalt := os.Getenv("API_SALT")
|
||
|
|
||
|
client := NewClient(apiURL, apiSalt)
|
||
|
|
||
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||
|
|
||
|
defer cancel()
|
||
|
|
||
|
response, err := client.Scrape(ctx, "https://news.ycombinator.com", ".athing .title")
|
||
|
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
fmt.Println(response.Content)
|
||
|
}
|
||
|
|
||
|
```
|
||
|
|
||
|
# License
|
||
|
|
||
|
WTFPL
|