1

So, I have a link for Tumblr API that gives the tagged posts with the given tag(https://api.tumblr.com/v2/tagged?api_key=blablabla&tag=red)

This the response from the request.

I want to just get the content of the <img src => , I want just the links inside, when I make a get request it loads the whole thing, I've tried puppeteer, fetch, document.getelementbyId("node js is screaming"), miserably failed..

How can I get just the links inside the <img src>

Ruben Helsloot
  • 12,582
  • 6
  • 26
  • 49
Hazim
  • 53
  • 1
  • 4
  • 2
    Stack overflow isn't a code writing service. There is plenty of information on how to scrape a website on Google. Pick an implementation, try it, and if you need help, come back and show us your code. – I wrestled a bear once. Aug 25 '20 at 13:14
  • Does this answer your question? [Extract image src from a string](https://stackoverflow.com/questions/14939296/extract-image-src-from-a-string) – Sandro Vardiashvili Aug 25 '20 at 13:15

1 Answers1

0

Fetch the response then scan it with a regex for img tags.

Example:

var response = 'your code response here'
var regex = /<img(.*?)>/g;
var imgtags = response.match(regex);
console.log(imgtags //);`

Now, imgtags contain all tags which start with "img", and you can use any arbitrary logic (including another custom regex) to select the one(s) you need.

Lioness100
  • 8,260
  • 6
  • 18
  • 49