From b1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c Mon Sep 17 00:00:00 2001 From: Philipp Tanlak Date: Mon, 24 Nov 2025 20:54:57 +0100 Subject: Docs --- public/docs/api-reference/index.html | 638 +++++++++++++++++++++++++++++++++++ 1 file changed, 638 insertions(+) create mode 100644 public/docs/api-reference/index.html (limited to 'public/docs/api-reference/index.html') diff --git a/public/docs/api-reference/index.html b/public/docs/api-reference/index.html new file mode 100644 index 0000000..5d50b5a --- /dev/null +++ b/public/docs/api-reference/index.html @@ -0,0 +1,638 @@ + + + + + + + + + + + + + + + API Reference – Flyscrape + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+
+
+
API Reference
+
+ +
+

API Reference

+

Query API +

Reference
// <div class="element" foo="bar">Hey</div>
+const el = doc.find(".element")
+el.text()                                 // "Hey"
+el.html()                                 // `<div class="element">Hey</div>`
+el.attr("foo")                            // "bar"
+el.hasAttr("foo")                         // true
+el.hasClass("element")                    // true
+
+// <ul>
+//   <li class="a">Item 1</li>
+//   <li>Item 2</li>
+//   <li>Item 3</li>
+// </ul>
+const list = doc.find("ul")
+list.children()                           // [<li class="a">Item 1</li>, <li>Item 2</li>, <li>Item 3</li>]
+
+const items = list.find("li")
+items.length()                            // 3
+items.first()                             // <li>Item 1</li>
+items.last()                              // <li>Item 3</li>
+items.get(1)                              // <li>Item 2</li>
+items.get(1).prev()                       // <li>Item 1</li>
+items.get(1).next()                       // <li>Item 3</li>
+items.get(1).parent()                     // <ul>...</ul>
+items.get(1).siblings()                   // [<li class="a">Item 1</li>, <li>Item 2</li>, <li>Item 3</li>]
+items.map(item => item.text())            // ["Item 1", "Item 2", "Item 3"]
+items.filter(item => item.hasClass("a"))  // [<li class="a">Item 1</li>]
+
+ +
+
+

Document Parsing +

Reference
import { parse } from "flyscrape";
+
+const doc = parse(`<div class="foo">bar</div>`);
+const text = doc.find(".foo").text();
+ +
+
+

File Downloads +

Reference
import { download } from "flyscrape/http";
+
+download("http://example.com/image.jpg")              // downloads as "image.jpg"
+download("http://example.com/image.jpg", "other.jpg") // downloads as "other.jpg"
+download("http://example.com/image.jpg", "dir/")      // downloads as "dir/image.jpg"
+
+// If the server offers a filename via the Content-Disposition header and no
+// destination filename is provided, Flyscrape will honor the suggested filename.
+// E.g. `Content-Disposition: attachment; filename="archive.zip"`
+download("http://example.com/generate_archive.php", "dir/") // downloads as "dir/archive.zip"
+
+ +
+
+ +
+
+ + +
+
+
+ + + + + + + + + + -- cgit v1.2.3