Skip to content

Instantly share code, notes, and snippets.

@Xananax
Created February 10, 2020 15:23
Show Gist options
  • Save Xananax/837e0cce3569771eed4b76428091ec28 to your computer and use it in GitHub Desktop.
Save Xananax/837e0cce3569771eed4b76428091ec28 to your computer and use it in GitHub Desktop.
Scrape Vimeo Video
const load = url => new Promise((ok, err) => require('https').request({ hostname: 'player.vimeo.com', port: 443, path: `/video/${url}`, method: 'GET'}, res => {
let data = ''
res.on('data', chunk => data+=chunk.toString())
res.on('end', () => ok(data.replace(/\n/g,'')))
}).on('error',err).end());
const extractTitle = html => (/<title>(.+?) on Vimeo<\/title>/gi.exec(html) || [])[1]
const extractAuthor = titleStr => ((/(.+?) from (.+)$/.exec(titleStr)) || [titleStr, titleStr, '']).slice(1, 3)
load('22685162').then(html => (console.log(html), html)).then(extractTitle).then(extractAuthor).then(console.log).catch(console.error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment