mirror of
https://github.com/postlight/mercury-parser
synced 2024-11-05 12:00:13 +00:00
fix: accepting cookies with request (required for sites like
nytimes.com)
This commit is contained in:
parent
74694ba8e2
commit
8fe3bec6b6
@ -22,5 +22,12 @@ describe('Iris', function() {
|
|||||||
|
|
||||||
// console.log(result)
|
// console.log(result)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('does the nyt', async function() {
|
||||||
|
const result = await Iris.parse('http://www.nytimes.com/2016/08/16/upshot/the-state-of-the-clinton-trump-race-is-it-over.html?_r=0')
|
||||||
|
|
||||||
|
// console.log(result)
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -21,9 +21,13 @@ export default async function fetchResource(url) {
|
|||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
url: parsedUrl,
|
url: parsedUrl,
|
||||||
headers: REQUEST_HEADERS,
|
headers: { ...REQUEST_HEADERS },
|
||||||
timeout: FETCH_TIMEOUT,
|
timeout: FETCH_TIMEOUT,
|
||||||
|
// Don't set encoding; this fixes issues
|
||||||
|
// w/gzipped responses
|
||||||
encoding: null,
|
encoding: null,
|
||||||
|
// Accept cookies
|
||||||
|
jar: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
const { response, body } = await get(options)
|
const { response, body } = await get(options)
|
||||||
|
@ -16,6 +16,13 @@ describe('fetchResource(url)', function() {
|
|||||||
|
|
||||||
assert.equal(typeof body, 'object')
|
assert.equal(typeof body, 'object')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('fetches nyt', async () => {
|
||||||
|
const url = 'http://www.nytimes.com/2016/08/16/upshot/the-state-of-the-clinton-trump-race-is-it-over.html?_r=0'
|
||||||
|
const { body, response } = await fetchResource(url)
|
||||||
|
|
||||||
|
assert.equal(typeof body, 'object')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('validateResponse(response)', () => {
|
describe('validateResponse(response)', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user