Skip to content

Commit 5eda055

Browse files
committed
Update example to use fetch and improved sidebar titles
1 parent 93cac41 commit 5eda055

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

docs/guides/python/python-crawl4ai.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Python headless browser web crawler example"
3-
sidebarTitle: "Python headless web crawler"
3+
sidebarTitle: "Headless web crawler"
44
description: "Learn how to use Python, Crawl4AI and Playwright to create a headless browser web crawler with Trigger.dev."
55
---
66

docs/guides/python/python-doc-to-markdown.mdx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
---
22
title: "Convert documents to markdown using Python and MarkItDown"
3-
sidebarTitle: "Python document to markdown"
3+
sidebarTitle: "Convert docs to markdown"
44
description: "Learn how to use Trigger.dev with Python to convert documents to markdown using MarkItDown."
55
---
66

77
import PythonLearnMore from "/snippets/python-learn-more.mdx";
88

9+
<Note>
10+
This project uses Trigger.dev v4 (which is currently in beta as of 28 April 2025). If you want to
11+
run this project you will need to [upgrade to v4](/docs/upgrade-to-v4).
12+
</Note>
13+
914
## Overview
1015

1116
Convert documents to markdown using Microsoft's [MarkItDown](https://github.com/microsoft/markitdown) library. This can be especially useful for preparing documents in a structured format for AI applications.
@@ -71,13 +76,11 @@ export default defineConfig({
7176
This task uses the `python.runScript` method to run the `markdown-converter.py` script with the given document URL as an argument.
7277

7378
```ts src/trigger/convertToMarkdown.ts
74-
import { task } from "@trigger.dev/sdk";
79+
import { task } from "@trigger.dev/sdk/v3";
7580
import { python } from "@trigger.dev/python";
7681
import * as fs from "fs";
7782
import * as path from "path";
7883
import * as os from "os";
79-
import * as https from "https";
80-
import * as http from "http";
8184

8285
export const convertToMarkdown = task({
8386
id: "convert-to-markdown",
@@ -92,18 +95,9 @@ export const convertToMarkdown = task({
9295
const tempFilePath = path.join(tempDir, `${fileName}${extension}`);
9396

9497
// STEP 2: Download file from URL
95-
await new Promise<void>((resolve, reject) => {
96-
const protocol = url.startsWith("https") ? https : http;
97-
const file = fs.createWriteStream(tempFilePath);
98-
99-
protocol.get(url, (response) => {
100-
response.pipe(file);
101-
file.on("finish", () => {
102-
file.close();
103-
resolve();
104-
});
105-
});
106-
});
98+
const response = await fetch(url);
99+
const buffer = await response.arrayBuffer();
100+
await fs.promises.writeFile(tempFilePath, Buffer.from(buffer));
107101

108102
// STEP 3: Run Python script to convert document to markdown
109103
const pythonResult = await python.runScript("./src/python/markdown-converter.py", [

docs/guides/python/python-image-processing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Python image processing example"
3-
sidebarTitle: "Python image processing"
3+
sidebarTitle: "Process images"
44
description: "Learn how to use Trigger.dev with Python to process images from URLs and upload them to S3."
55
---
66

docs/guides/python/python-pdf-form-extractor.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Python PDF form extractor example"
3-
sidebarTitle: "Python PDF form extractor"
3+
sidebarTitle: "Extract form data from PDFs"
44
description: "Learn how to use Trigger.dev with Python to extract form data from PDF files."
55
---
66

0 commit comments

Comments
 (0)