Created
June 13, 2019 12:47
-
-
Save codeboy5/27a9a6b096ce86a4cf7b736774be7b6b to your computer and use it in GitHub Desktop.
Script for extracting urls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cheerio from "cheerio"; | |
const html: string = ` | |
<script src="https://cdn.jsdelivr.net/npm/publicalbum@latest/dist/pa-embed-player.min.js" async></script> | |
<div class="pa-embed-player" style="width:100%; height:480px; display:none;" | |
data-link="https://photos.app.goo.gl/rxNdA9kHxDryXtKBA" | |
data-title="demo" | |
data-description="2 new photos added to shared album"> | |
<img data-src="https://lh3.googleusercontent.com/GSyOvrN9UD2EL02eqNIp1HRF82oVNT9goSZkLBSLKNl_p6bly_WL5z8DE4yZyVRbESpYsRqlJAWbW-k5NO8Yp-F1yhVsFCuv1RDWdAK_SWDvGN4FBMA7_UUbLKLBRtBAoX-YHT8w4g=w1920-h1080" src="" alt="" /> | |
<img data-src="https://lh3.googleusercontent.com/0evJ2xDdFqVccYAdKudLCXbNQA6FOtvr2oWP7pNlSHD8FpzEiELe92ZGlG1Z2dGHVelu9lODhQ1CqPO2Q-ZRD0vUZpCz9TisnzqlCEUHHMn06XnjnlHz5QDuKyzOgkVNIqGVGJ2_sQ=w1920-h1080" src="" alt="" /> | |
</div> | |
`; | |
const $ = cheerio.load(html); | |
const urls: never[] | string[] = []; | |
$("img").each(function(i, elem) { | |
urls[i] = $(elem).attr("data-src"); | |
}); | |
console.log(urls); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment