async function scrape(embedURL) { const fid = embedURL.split('/')[4]; const {body} = await got(`https://megaxfer.ru/player?fid=${fid}&page=embed`, {json: true}); const {html} = body; const regexData = REGEX.exec(html); if (!regexData || !regexData[1]) { return null; } return json5.parse(regexData[1]); }
async function scrape(embedURL) { const {body} = await got(embedURL); const regexData = REGEX.exec(body); if (!regexData || !regexData[1]) { return null; } return regexData[1]; }
suite('example', () => { suite('/', () => { test('should return an example message', async () => { const response = await got(`http://localhost:${instance.server.address().port}/v1/example`, { json: true }); response.statusCode.should.be.equal(200); response.body.message.should.be.equal('example'); }); }); });
got(url, myOptions) .then(response => { return Promise.resolve(response.body); }) .catch(err => { debug(err); return Promise.reject( err.response && err.response.body ? err.response.body : err ); })
async function queryApi(method, resource, options) { const customOptions = Object.assign({}, options, { json: true, method }); let response; try { response = await got(`http://localhost:${PORT}${resource}`, customOptions); } catch (error) { response = error.response; } return response; }
async function getUUID(username) { const res = await got(`https://mcuuid.net/?q=${username}`); const $ = cheerio.load(res.body); const input = $('input')[1]; if (!input) { return; } return input.attribs['value']; }
got('https://memegen.link/templates/').then(res => { let data = JSON.parse(res.body); templates = []; let promises = []; for (let key in data) { promises.push(_loadMeme(data[key])); } Promise.all(promises).then(() => { templates = templates.filter(e => !!e); templates.sort((a, b) => a.name.localeCompare(b.name)); }).catch(console.error); }).catch(console.error);
page .then(async (request) => { const response = await got(request.url, request) console.log(response.body) })
async function scrape(embedURL) { const response = await got(embedURL); const body = response.body; const packed = packedRegex.exec(body)[1]; const unpacked = unpacker.unPack(packed); const sources = jsonRegex.exec(unpacked); const parsed = json5.parse(sources[1]); return parsed; }
got(`${registryUrl}${packageName}`) .then(result => { return Promise.resolve(JSON.parse(result.body)) }) .catch(error => { return Promise.reject(error) })
async function searchMovies(query, page=1, pageSize=0) { const body = JSON.stringify({ content_types: ['movie'], page, page_size: pageSize, query }); const response = await got(`${API_SEARCH}?body=${body}`, { json: true }); return response.body; }
async function scrape(url) { const response = await got(url); const body = response.body; // Dirty check to see if the file exists if (body.includes('We are unable to find the video you\'re looking for. There could be several reasons for this, for example it got removed by the owner.')) { return null; } return parse(body); }
async function movieDetails(id) { const response = await got(API_MOVIE_DETAILS.replace('{id}', id), { json: true }); return response.body; }
async function scrape(embedURL) { const {body} = await got(embedURL); let sources = sourcesRegex.exec(body); if (sources && sources[1]) { sources = JSON5.parse(sources[1]); } return sources; }
async function searchShows(query, page=1, pageSize=0) { const body = JSON.stringify({ content_types: ['show'], page, page_size: pageSize, query }); const response = await got(`${API_SEARCH}?body=${body}`, { json: true }); return response.body; }