Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ linkup search "query" --include-domains linkup.so --from-date 2025-01-01

Extract the content of a URL as markdown.

- Select `--mode standard` (default) or `--mode pro` for harder-to-retrieve pages.
- Use `--render-js` for JS-heavy pages.
- Add `--include-raw-content` to include the source page content.
- The deprecated `--include-raw-html` flag remains available for compatibility.
- Add `--extract-images` to include image metadata.

```bash
linkup fetch https://example.com --render-js
linkup fetch https://example.com --mode pro --render-js
```

### Asynchronous commands
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@inquirer/prompts": "^8.5.2",
"commander": "^13.1.0",
"linkup-sdk": "^3.4.0",
"linkup-sdk": "^3.5.0",
"open": "^11.0.0"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions src/__tests__/fetch.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ describe('fetch command integration', () => {
'linkup',
'fetch',
'https://example.com',
'--mode',
'pro',
'--render-js',
'--include-raw-content',
'--extract-images',
Expand All @@ -26,6 +28,7 @@ describe('fetch command integration', () => {
expect(fakeClient.fetch).toHaveBeenCalledWith({
extractImages: true,
includeRawContent: true,
mode: 'pro',
renderJs: true,
url: 'https://example.com',
});
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ describe('buildFetchParams', () => {
extractImages: true,
includeRawContent: true,
includeRawHtml: true,
mode: 'pro',
renderJs: true,
}),
).toEqual({
extractImages: true,
includeRawContent: true,
includeRawHtml: true,
mode: 'pro',
renderJs: true,
url: 'https://example.com',
});
Expand Down
11 changes: 9 additions & 2 deletions src/commands/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { type Command, InvalidArgumentError } from 'commander';
import type { FetchParams, TaskRequest } from 'linkup-sdk';
import { type Command, InvalidArgumentError, Option } from 'commander';
import type { FetchMode, FetchParams, TaskRequest } from 'linkup-sdk';
import { resolveGlobals } from '../client.js';
import { exitWithError, formatErrorLine } from '../output/errors.js';
import { formatFetch } from '../output/fetch.js';
import { formatTaskErrorLine } from '../output/task-errors.js';
import { createPollIntervalOption, createTimeoutOption, runTaskFlow } from './async-task.js';

type FetchCommandOptions = {
mode?: FetchMode;
renderJs?: boolean;
includeRawContent?: boolean;
includeRawHtml?: boolean;
Expand All @@ -29,6 +30,7 @@ function parseFetchUrl(value: string): string {
export function buildFetchParams(url: string, options: FetchCommandOptions): FetchParams {
return {
url,
...(options.mode && { mode: options.mode }),
...(options.renderJs && { renderJs: true }),
...(options.includeRawContent && { includeRawContent: true }),
...(options.includeRawHtml && { includeRawHtml: true }),
Expand Down Expand Up @@ -67,11 +69,15 @@ async function runFetch(
}

export function registerFetchCommand(program: Command): void {
const modeChoices: FetchMode[] = ['standard', 'pro'];
const modeOption = new Option('--mode <mode>', 'Fetch mode').choices(modeChoices);

program
.command('fetch')
.alias('f')
.description('Fetch and extract content from a URL')
.argument('<url>', 'URL to fetch', parseFetchUrl)
.addOption(modeOption)
.option('--render-js', 'Execute JavaScript before extracting content')
.option('--include-raw-content', 'Include the raw page content in the response output')
.option('--include-raw-html', 'Include legacy raw HTML in the response output')
Expand All @@ -85,6 +91,7 @@ export function registerFetchCommand(program: Command): void {
`
Examples:
linkup fetch https://example.com
linkup fetch https://example.com --mode pro
linkup fetch https://example.com --render-js
linkup fetch https://example.com --include-raw-content --json
linkup fetch https://example.com --async --wait
Expand Down