diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2024-02-21 21:39:37 +0100 |
|---|---|---|
| committer | Philipp Tanlak <philipp.tanlak@gmail.com> | 2024-02-21 21:39:37 +0100 |
| commit | e2e0ed8fa7d26a23f77b378907b3f902be9e028e (patch) | |
| tree | f47717a3db0aba9e74cb67ce7ef4137f3d1da2d7 /examples | |
| parent | c796f4164c13e30135246c08304acd7142673f60 (diff) | |
Use the cookie store from local browser
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/cookies.js | 14 | ||||
| -rw-r--r-- | examples/hackernews_login.js | 18 |
2 files changed, 14 insertions, 18 deletions
diff --git a/examples/cookies.js b/examples/cookies.js new file mode 100644 index 0000000..6132daf --- /dev/null +++ b/examples/cookies.js @@ -0,0 +1,14 @@ +export const config = { + url: "https://news.ycombinator.com/", + + // This will use cookies from your Chrome browser. + // Options: "chrome" | "firefox" | "edge" + cookies: "chrome", +}; + +export default function({ doc }) { + return { + user: doc.find("#me").text(), + karma: doc.find("#karma").text(), + } +} diff --git a/examples/hackernews_login.js b/examples/hackernews_login.js deleted file mode 100644 index 486b736..0000000 --- a/examples/hackernews_login.js +++ /dev/null @@ -1,18 +0,0 @@ -import http from "flyscrape/http" - -export const config = { - url: "https://news.ycombinator.com", -} - -export function setup() { - http.postForm("https://news.ycombinator.com/login", { - "acct": "my-username", - "pw": "my-password", - }) -} - -export default function ({ doc }) { - return { - karma: doc.find("#karma").text() - } -} |