Guest User

Untitled

a guest
Sep 17th, 2020
26
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const puppeteer = require('puppeteer');
  2. const playmusic = async (page) => {
  3. await page.goto('http://www.noiseaddicts.com/free-samples-mp3/?id=2544');
  4. return page.click('span.map_play');
  5. }
  6.  
  7. (async () => {
  8. const browser = await puppeteer.launch({headless : false});
  9.  
  10. const page = await browser.newPage();
  11.  
  12.  
  13. await page.goto('MYURL');
  14. const pricing = await page.evaluate(()=>{
  15. let pricesOnPage=document.querySelectorAll(".span_price_wrap");
  16. const priceList=[...pricesOnPage];
  17. return priceList.map(h=>h.innerText);
  18.  
  19. });
  20. console.log(pricing[1]);
  21.  
  22. if(pricing[1]>=2300)
  23. {
  24. try {
  25. await page.evaluate(async () => {
  26. try {
  27. await playmusic(page);
  28. } catch(e) {
  29. console.log(e);
  30. //process.exit(1);
  31. }
  32. });
  33. } catch(e) {
  34. console.log(e);
  35. //process.exit(1)
  36. }
  37. }
  38.  
  39.  
  40.  
  41.  
  42. await browser.close();
  43. })();
  44.  
  45.  
RAW Paste Data