-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #292 from ndaidong/7.1.0
v7.1.0 - To work with `bun` and `deno`
- Loading branch information
Showing
14 changed files
with
147 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "article-parser-cjs", | ||
"version": "7.0.3", | ||
"version": "7.1.0", | ||
"main": "./article-parser.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
// utils -> retrieve | ||
|
||
import axios from 'axios' | ||
|
||
import { getRequestOptions } from '../config.js' | ||
import fetch from 'cross-fetch' | ||
|
||
export default async (url) => { | ||
try { | ||
const res = await axios.get(url, getRequestOptions()) | ||
|
||
const contentType = res.headers['content-type'] || '' | ||
if (!contentType || !contentType.includes('text/html')) { | ||
throw new Error(`Content type must be "text/html", not "${contentType}"`) | ||
const res = await fetch(url, { | ||
headers: { | ||
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0' | ||
} | ||
return res.data | ||
} catch (err) { | ||
throw new Error(`${err.name}: ${err.message}`) | ||
}) | ||
const contentType = res.headers.get('content-type') || '' | ||
if (!contentType || !contentType.includes('text/')) { | ||
throw new Error(`Content type must be "text/html", not "${contentType}"`) | ||
} | ||
return res.text() | ||
} |