[scraper] fixes hs api to not use redirects due to node hotfix
This commit is contained in:
@@ -45,13 +45,13 @@ function _getContent(endpoint, config = {},) {
|
|||||||
? endpoint.replace(/https?:\/\/[^/]+/, baseUrl)
|
? endpoint.replace(/https?:\/\/[^/]+/, baseUrl)
|
||||||
: `${baseUrl}${endpoint}`;
|
: `${baseUrl}${endpoint}`;
|
||||||
|
|
||||||
return needle('get', url, { open_timeout: timeout, follow: 2 })
|
return needle('get', url, { open_timeout: timeout })
|
||||||
.then((response) => response.body)
|
.then((response) => response.body)
|
||||||
.then((body) => cheerio.load(body));
|
.then((body) => cheerio.load(body));
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getShowId(showEndpoint) {
|
function _getShowId(showEndpoint) {
|
||||||
return _getContent(showEndpoint)
|
return _getContent(showEndpoint.replace(/(?:#\d+)?\/?$/, '/'))
|
||||||
.then($ => $('div.entry-content').find('script').html().match(/var hs_showid = (\d+)/)[1]);
|
.then($ => $('div.entry-content').find('script').html().match(/var hs_showid = (\d+)/)[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user