anshulrgoyal / imdb-scrapper

This is small project it provide many good api for search ,scrapping ,trending
39 stars 32 forks source link

Added actor info and actor search #14

Closed 0c0de closed 6 years ago

0c0de commented 6 years ago

Fixes issue

6

anshulrgoyal commented 6 years ago

Also please convert the images to the high quality images and example is available in the lib/photo.js

anshulrgoyal commented 6 years ago

also convert the image url to high quality

0c0de commented 6 years ago

I'm unable to get high quality image working because return undefined the url so I cannot modify it and because of this, node server throws an error but it is strange because with a console.log I can see that all is correct and urls printed are in the correct format... :thinking: this is my code BTW. Do you know why happens this? :thinking:

function searchActor(keyword){

  return request(`https://www.imdb.com/find?ref_=nv_sr_fn&q=${keyword}&s=nm`).then((data) => {
    const $ = cheerio.load(data);
    let result = [];
    console.log(keyword);
    result.push({
      searchQuery: keyword
    });
    $('tr').each((index, element) => {

      var image = $(element).find('td.primary_photo > a > img').attr('src');
      var name = $(element).find('td.result_text > a').text();
      image = JSON.stringify(image);
      image = image.split("@._")[0] += '@._V1_UX1024_CR1024,1024,0,0_AL_.jpg"';
      console.log(image);
      result.push({
        actorImage: image,
        actorName: name
      });
    });
    return result;
  }).catch(ifError)
}
anshulrgoyal commented 6 years ago

Just put in try catch block

0c0de commented 6 years ago

It is ok now? :thinking:

0c0de commented 6 years ago

Now have the id