Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. var url = inputData.url
  2.  
  3. fetch(url)
  4. .then(res => res.text())
  5. .then(body => {
  6. const description = body.match(/<\/center>[\s\S]+<p>([\s\S]+<b> Explanation:[\s\S]+)<p> <center>/i)[1]
  7. const copyright = body.match(/(<b> Image Credit[\s\S]+<\/b>[\s\S]+)<\/center> <p>/i)[1]
  8. var imagePath = body.match(/<img src="([^"]+)"/i)[1]
  9. const imageURL = 'https://apod.nasa.gov/apod/' + imagePath
  10. var output = { url, imageURL, description, copyright }
  11. callback(null, output)
  12. })
  13. .catch(callback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement