Scraping amazon with puppeteer

I’m currently working on some personal projects and I just had the idea to do some amazon scraping so I can get the products details like the name and price.

I found that the most consistent view that used the same id’s for product name and price was the mobile view so that’s why I’m using it.

The problem is that I can’t get the price.

I’ve done the same exactly query selector for the name (that works) in the price but with no success.

const puppeteer = require('puppeteer');

const url = 'https://www.amazon.com/dp/B01MUAGZ49';

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();
  await page.setViewport({ width: 360, height: 640 });
  await page.goto(url);

  let producData = await page.evaluate(() => {
    let productDetails = [];

    let elements = document.querySelectorAll('#a-page');

    elements.forEach(element => {
      let detailsJson = {};

      try {
        detailsJson.name = element.querySelector('h1#title').innerText;
        detailsJson.price = element.querySelector('#newBuyBoxPrice').innerText;
      } catch (exception) {}

      productDetails.push(detailsJson);
    });

    return productDetails;
  });

  console.dir(producData);
})();

I should get the name and the price in the console.dir but right now I only get

[ { name: 'Nintendo Switch – Neon Red and Neon Blue Joy-Con ' } ]

98 thoughts on “Scraping amazon with puppeteer”

  1. I really like your blog.. very nice colors & theme.

    Did you make this website yourself or did you hire
    someone to do it for you? Plz answer back as I’m looking to create my
    own blog and would like to find out where u got this from.

    many thanks

    Reply
  2. Admiring the persistence you put into your site and detailed information you offer.
    It’s nice to come across a blog every once in a while that isn’t the same unwanted rehashed material.

    Excellent read! I’ve saved your site and I’m including your RSS feeds to my Google account.

    Reply
  3. I absolutely love your blog and find nearly all of your post’s to be just what I’m looking
    for. Do you offer guest writers to write content available for you?

    I wouldn’t mind producing a post or elaborating on a number of the subjects you
    write about here. Again, awesome website!

    Reply
  4. Hello I am so happy I found your blog, I really found you by
    mistake, while I was browsing on Aol for something else, Regardless I am
    here now and would just like to say kudos for a fantastic
    post and a all round enjoyable blog (I also love the theme/design), I don’t have time to read through it all at the minute but I have bookmarked it and also added in your RSS feeds, so when I have time I
    will be back to read a great deal more, Please do keep up the excellent job.

    Reply
  5. Wonderful website you have here but I was wanting to know if you knew of any user discussion forums that cover the
    same topics talked about in this article? I’d
    really like to be a part of community where I
    can get comments from other experienced individuals that share the same interest.
    If you have any recommendations, please let me know.
    Thanks!

    Reply
  6. After looking at a few of the blog posts on your web site,
    I honestly appreciate your way of writing a blog.

    I added it to my bookmark webpage list and will be checking back soon. Please check out my website
    too and let me know your opinion.

    Reply
  7. This design is incredible! You definitely know how to keep
    a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Great job.
    I really enjoyed what you had to say, and more than that, how you
    presented it. Too cool!

    Reply
  8. Hello there, just became aware of your blog through Google, and found that it’s truly
    informative. I’m gonna watch out for brussels. I’ll be
    grateful if you continue this in future. Many people will be benefited from your writing.
    Cheers!

    Reply
  9. I truly love your website.. Very nice colors & theme.
    Did you create this amazing site yourself? Please reply back as I’m looking to create my own personal website and want to learn where you got this from or what
    the theme is named. Thanks!

    Reply
  10. Fantastic beat ! I wish to apprentice while you amend your site, how
    could i subscribe for a blog site? The account
    helped me a appropriate deal. I were tiny bit familiar of this your broadcast offered vibrant transparent idea

    Reply
  11. After I originally left a comment I seem to have clicked the -Notify me when new comments are added- checkbox and from now on each time a comment is added I get 4 emails with the exact same comment.
    Perhaps there is a way you are able to remove me from that service?
    Kudos!

    Reply
  12. I am really enjoying the theme/design of your blog.
    Do you ever run into any browser compatibility issues?

    A number of my blog audience have complained about my website not working correctly in Explorer but looks great in Opera.
    Do you have any advice to help fix this issue?

    Reply
  13. Thanks for the marvelous posting! I genuinely enjoyed reading it, you could be a great author.
    I will make sure to bookmark your blog and will eventually come back very soon. I want to encourage one to continue your great
    writing, have a nice afternoon!

    Reply
  14. I loved as much as you will receive carried out right here.
    The sketch is tasteful, your authored subject matter stylish.
    nonetheless, you command get got an edginess over that you wish be delivering the following.
    unwell unquestionably come more formerly again as exactly the same nearly very often inside case you shield this increase.

    Reply
  15. Веб-площадка Джойказино
    появилась на российском рынке более 7 лет назад.
    Посетителям веб-сервиса предоставляется сертифицированный программный продукт от проверенных временем разработчиков.
    В подборку виртуальных продуктов вошли аппараты барабанного типа, карточные и настольные игры в режиме live
    и ставки на спорт и киберспортивные дисциплины.

    Reply
  16. Hey there just wanted to give you a quick heads up. The text in your article seem to be running off the screen in Opera.

    I’m not sure if this is a formatting issue or something
    to do with browser compatibility but I figured I’d post to let you know.
    The design look great though! Hope you get the problem fixed soon. Kudos

    Reply
  17. Fantastic beat ! I would like to apprentice while you amend your website, how could i subscribe for a blog
    website? The account helped me a acceptable deal.
    I had been tiny bit acquainted of this your broadcast offered bright clear idea

    Reply
  18. I loved as much as you will receive carried out right here.

    The sketch is tasteful, your authored subject matter stylish.

    nonetheless, you command get bought an shakiness over that you wish be delivering the following.

    unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield this hike.

    Reply
  19. Simply want to say your article is as astonishing. The clarity
    for your put up is just excellent and i can assume you are an expert on this subject.
    Well along with your permission allow me to seize your feed to stay up to date with approaching post.
    Thank you one million and please carry on the rewarding work.

    Reply
  20. I do not even know how I stopped up right here, however I believed
    this post used to be good. I do not understand who you might be however certainly you are going to a famous blogger
    in the event you are not already. Cheers!

    Reply
  21. Hiya very cool website!! Guy .. Excellent .. Wonderful .. I will bookmark your website and take the feeds additionally?

    I am satisfied to find a lot of helpful info right here
    in the put up, we’d like develop extra techniques on this regard, thanks for sharing.
    . . . . .

    Reply
  22. I have to thank you for the efforts you have put in penning this site.

    I’m hoping to view the same high-grade blog posts from you later
    on as well. In truth, your creative writing abilities has encouraged me to get my
    very own blog now 😉

    Reply
  23. I’ve read a few just right stuff here. Certainly value
    bookmarking for revisiting. I surprise how much attempt you set to make one of these great informative website.

    Reply
  24. Hello there! This is my first comment here so I just wanted
    to give a quick shout out and say I genuinely enjoy reading
    your blog posts. Can you recommend any other blogs/websites/forums that go
    over the same topics? Appreciate it!

    Reply
  25. Thanks for your marvelous posting! I actually enjoyed reading it, you may
    be a great author. I will make sure to bookmark your blog and will come back later
    in life. I want to encourage continue your great job, have a nice evening!

    Reply
  26. Hello! Would you mind if I share your blog with my twitter group?
    There’s a lot of people that I think would really enjoy your content.

    Please let me know. Cheers

    Reply
  27. Heya just wanted to give you a brief heads up and let you know a
    few of the pictures aren’t loading properly.
    I’m not sure why but I think its a linking issue. I’ve tried
    it in two different browsers and both show the same outcome.

    Reply
  28. Hey would you mind letting me know which webhost you’re working with?
    I’ve loaded your blog in 3 completely different internet browsers and
    I must say this blog loads a lot quicker then most. Can you suggest a good web hosting provider at
    a reasonable price? Cheers, I appreciate it!

    Reply
  29. Hey there just wanted to give you a quick heads up and let you know
    a few of the images aren’t loading properly. I’m not sure why but I think its a linking issue.
    I’ve tried it in two different internet browsers and both show the same outcome.

    Reply
  30. My developer is trying to convince me to move to
    .net from PHP. I have always disliked the idea
    because of the costs. But he’s tryiong none the less.
    I’ve been using Movable-type on various websites for about a
    year and am worried about switching to another platform.
    I have heard good things about blogengine.net.
    Is there a way I can transfer all my wordpress content into it?
    Any kind of help would be really appreciated!

    Reply
  31. Awesome site you have here but I was wanting to know if you knew of
    any discussion boards that cover the same topics talked about here?

    I’d really like to be a part of online community
    where I can get suggestions from other experienced individuals that share the
    same interest. If you have any recommendations, please let me know.
    Thanks!

    Reply
  32. Thanks for ones marvelous posting! I actually enjoyed reading it, you will be a great author.
    I will ensure that I bookmark your blog and will eventually come back
    down the road. I want to encourage you to definitely continue your great
    work, have a nice afternoon!

    Reply
  33. You really make it seem really easy with your presentation however
    I find this matter to be really something which I think I’d by no means understand.
    It seems too complicated and very broad for me. I’m having
    a look ahead on your subsequent put up, I will try to get the dangle
    of it!

    Reply
  34. Hi would you mind stating which blog platform you’re working with?

    I’m looking to start my own blog soon but I’m having a difficult time
    choosing between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs
    and I’m looking for something completely unique.
    P.S Apologies for being off-topic but I had to ask!

    Reply
  35. It’s the best time to make some plans for the future and it’s time
    to be happy. I’ve read this post and if I could I wish to suggest
    you few interesting things or advice. Maybe you can write next articles referring to this article.
    I want to read more things about it!

    Reply
  36. Hello, i believe that i saw you visited my site so i got here to
    go back the want?.I am attempting to in finding things to
    improve my web site!I guess its good enough to use a few of your
    ideas!!

    Reply
  37. Thank you, I have just been searching for information approximately this
    topic for a while and yours is the greatest I’ve found out till now.
    But, what in regards to the bottom line? Are
    you positive concerning the source?

    Reply
  38. hi!,I really like your writing very so much! share
    we communicate more about your post on AOL? I need a specialist in this space to solve my problem.
    May be that’s you! Taking a look ahead to see you.

    Reply
  39. I was suggested this web site through my cousin. I’m now not positive whether or not this put up is written via
    him as nobody else realize such certain approximately my difficulty.
    You are amazing! Thanks!

    Reply
  40. I’m truly enjoying the design and layout of your site.
    It’s a very easy on the eyes which makes it much more pleasant
    for me to come here and visit more often. Did you hire out a designer
    to create your theme? Exceptional work!

    Reply
  41. Appreciating the time and effort you put into your website and detailed information you provide.
    It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material.
    Great read! I’ve saved your site and I’m adding your RSS feeds to my Google account.

    Reply
  42. You really make it seem so easy with your
    presentation but I find this topic to be really something which I think I would never understand.

    It seems too complicated and very broad for me. I
    am looking forward for your next post, I’ll
    try to get the hang of it!

    Reply
  43. I do not even know the way I stopped up right here, but I
    thought this publish was once great. I do not understand who you’re however definitely you are going
    to a well-known blogger should you aren’t already.
    Cheers!

    Reply
  44. Definitely believe that which you stated. Your favorite justification seemed to be on the web the simplest thing to take into accout of.

    I say to you, I definitely get irked while other people think about issues that they plainly don’t recognize about.
    You controlled to hit the nail upon the highest as neatly as defined out
    the entire thing with no need side-effects , other folks can take a signal.
    Will likely be again to get more. Thank you

    Reply
  45. Good day! I know this is kind of off topic but I was wondering which blog platform are you
    using for this site? I’m getting sick and tired of WordPress because I’ve had problems