summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2023-11-01 21:20:40 +0100
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2023-11-01 21:20:40 +0100
commitaadd80b3b213988aa5701075f2650198e4066349 (patch)
tree23d61848106682a0c72338c07c37d6b9f87a1b47 /examples
parent2d3cd6584dedce45ea709d1757a28ce7537f3472 (diff)
Add login functionality
Diffstat (limited to 'examples')
-rw-r--r--examples/hackernews_login.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/hackernews_login.js b/examples/hackernews_login.js
new file mode 100644
index 0000000..371b8b7
--- /dev/null
+++ b/examples/hackernews_login.js
@@ -0,0 +1,20 @@
+import { submitForm } from "flyscrape"
+
+export const config = {
+ url: "https://news.ycombinator.com",
+}
+
+export function login() {
+ const formData = {
+ "acct": "my-username",
+ "pw": "my-password",
+ }
+
+ submitForm("https://news.ycombinator.com/login", formData)
+}
+
+export default function ({ doc }) {
+ return {
+ karma: doc.find("#karma").text()
+ }
+}