Skip to content

Commit 85ef318

Browse files
authored
Merge pull request #94 from extractus/6.2.4
v6.2.4
2 parents d578bdc + 30f3df8 commit 85ef318

File tree

8 files changed

+150
-109
lines changed

8 files changed

+150
-109
lines changed

.github/workflows/ci-test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
node-version: ${{ matrix.node_version }}
2424

2525
- name: run npm scripts
26+
env:
27+
PROXY_SERVER: ${{ secrets.PROXY_SERVER }}
2628
run: |
2729
npm install
2830
npm run lint

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,26 @@ await extract(url, null, {
214214
Passing requests to proxy is useful while running `@extractus/feed-extractor` on browser.
215215
View `examples/browser-feed-reader` as reference example.
216216

217+
Another way to work with proxy is use `agent` option instead of `proxy` as below:
218+
219+
```js
220+
import { extract } from '@extractus/feed-extractor'
221+
222+
import { HttpsProxyAgent } from 'https-proxy-agent'
223+
224+
const proxy = 'http://abc:[email protected]:31113'
225+
226+
const url = 'https://news.google.com/rss'
227+
228+
const feed = await extract(url, null, {
229+
agent: new HttpsProxyAgent(proxy),
230+
})
231+
console.log('Run feed-extractor with proxy:', proxy)
232+
console.log(feed)
233+
```
234+
235+
For more info about [https-proxy-agent](https://www.npmjs.com/package/https-proxy-agent), check [its repo](https://github.com/TooTallNate/proxy-agents).
236+
217237

218238
### `extractFromJson()`
219239

dist/cjs/feed-extractor.js

Lines changed: 57 additions & 57 deletions
Large diffs are not rendered by default.

dist/cjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "@extractus/feed-extractor",
3-
"version": "6.2.3",
3+
"version": "6.2.4",
44
"main": "./feed-extractor.js"
55
}

dist/feed-extractor.esm.js

Lines changed: 43 additions & 43 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "6.2.3",
2+
"version": "6.2.4",
33
"name": "@extractus/feed-extractor",
44
"description": "To read and normalize RSS/ATOM/JSON feed data",
55
"homepage": "https://extractor-demos.pages.dev",
@@ -36,14 +36,15 @@
3636
},
3737
"dependencies": {
3838
"bellajs": "^11.1.2",
39-
"cross-fetch": "^3.1.6",
40-
"fast-xml-parser": "^4.2.4",
41-
"html-entities": "^2.3.6"
39+
"cross-fetch": "^4.0.0",
40+
"fast-xml-parser": "^4.2.5",
41+
"html-entities": "^2.4.0"
4242
},
4343
"devDependencies": {
44-
"esbuild": "^0.18.2",
45-
"eslint": "^8.42.0",
46-
"jest": "^29.5.0",
44+
"esbuild": "^0.18.11",
45+
"eslint": "^8.44.0",
46+
"https-proxy-agent": "^7.0.0",
47+
"jest": "^29.6.0",
4748
"nock": "^13.3.1"
4849
},
4950
"keywords": [

src/main.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
import { readFileSync } from 'fs'
55

66
import nock from 'nock'
7+
import { HttpsProxyAgent } from 'https-proxy-agent'
78

89
import { hasProperty, isString } from 'bellajs'
910

1011
import { extract, extractFromXml, extractFromJson, read } from './main.js'
1112
import { isValid as isValidUrl } from './utils/linker.js'
1213

14+
const env = process.env || {}
15+
const PROXY_SERVER = env.PROXY_SERVER || ''
16+
1317
const feedAttrs = 'title link description generator language published entries'.split(' ')
1418
const entryAttrs = 'title link description published id'.split(' ')
1519

@@ -395,6 +399,19 @@ describe('test extract with `baseUrl` option', () => {
395399
})
396400
})
397401

402+
if (PROXY_SERVER !== '') {
403+
describe('test extract live RSS via proxy server', () => {
404+
test('check if extract method works with proxy server', async () => {
405+
const url = 'https://news.google.com/rss'
406+
const result = await extract(url, {}, {
407+
agent: new HttpsProxyAgent(PROXY_SERVER),
408+
})
409+
expect(result.title).toContain('Google News')
410+
expect(result.entries.length).toBeGreaterThan(0)
411+
}, 10000)
412+
})
413+
}
414+
398415
describe('check old method read()', () => {
399416
test('ensure that depricated method read() still works', async () => {
400417
const url = 'https://realworld-standard-feed.tld/rss'

src/utils/retrieve.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ export default async (url, options = {}) => {
1919
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0',
2020
},
2121
proxy = null,
22+
agent = null,
2223
} = options
2324

24-
const res = proxy ? await profetch(url, proxy) : await fetch(url, { headers })
25+
const res = proxy ? await profetch(url, proxy) : await fetch(url, { headers, agent })
2526

2627
const status = res.status
2728
if (status >= 400) {

0 commit comments

Comments
 (0)