Skip to content

Commit

Permalink
Merge pull request #754 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Jan 25, 2023
2 parents 4c453b3 + 54aea54 commit eddc0da
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/v2/bloomberg/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const apiEndpoints = {
},
videos: {
url: 'https://www.bloomberg.com/news/videos/',
sel: '.footer-container + script',
sel: 'script',
},
newsletters: {
url: 'https://www.bloomberg.com/news/newsletters/',
Expand Down Expand Up @@ -153,7 +153,9 @@ const parseAudioPage = async (res, api, item) => {
};

const parseVideoPage = async (res, api, item) => {
const json = cheerio.load(res.data)(api.sel).text().trim().replace('window.__PRELOADED_STATE__ = ', '').slice(0, -1);
const $ = cheerio.load(res.data);
const script = $(api.sel).filter((i, el) => $(el).text().includes('__PRELOADED_STATE__'));
const json = script.text().trim().replace('window.__PRELOADED_STATE__ = ', '').slice(0, -1);
const article_json = JSON.parse(json);
const video_story = article_json.video?.videoStory ?? article_json.quicktakeVideo?.videoStory;
if (video_story) {
Expand Down

1 comment on commit eddc0da

@vercel
Copy link

@vercel vercel bot commented on eddc0da Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.