skip to Main Content

I’m trying to parse imdb movie connections (https://www.imdb.com/title/tt0090887/movieconnections/), but more button don’t load info in each category (featured in, followeb by…). Puppeteer click function doesn’t work because it’s a kind of javascript function

enter image description here

const puppeteer = require('puppeteer');

const scrape = async function () {
const browser = await puppeteer.launch({ headless: false });

const page = await browser.newPage();
await page.goto('https://www.imdb.com/title/tt0090887/movieconnections/');
await page.click('.ipc-see-more__button');

3

Answers


  1. Chosen as BEST ANSWER

    I've this code now:

    const puppeteer = require('puppeteer');
    
    const scrape = async function () {
        const browser = await puppeteer.launch({ headless: false });
    
        const page = await browser.newPage();
        await page.goto('https://www.imdb.com/title/tt0090887/movieconnections/');
        await page.waitForSelector('.ipc-see-more__button');
       // await page.click('.ipc-see-more__button');
        await page.evaluate(() => {
            const buttons = document.querySelectorAll('button')
            
            buttons.forEach(button => {
                if(button.className.includes(".ipc-see-more__button")) {
                  button.click()
                }
            })
          })
    
        // logging results
       // console.log(quotes);
       // await browser.close();
    
    };
    scrape()
    

    but doesn't press the button


  2.     const puppeteer = require('puppeteer');
    
    const scrape = async function () {
        const browser = await puppeteer.launch({ headless: false });
    
        const page = await browser.newPage();
        await page.goto('https://www.imdb.com/title/tt0090887/movieconnections/');
        await page.waitForSelector('.ipc-see-more__button');
       // await page.click('.ipc-see-more__button');
        await page.evaluate(() => {
            const buttons = [...document.querySelectorAll('.ipc-see-more__button')]
            const buttonsMore = buttons.filter(button => button.innerText.includes('more')) 
            buttonsMore.forEach(button => {
                  button.click()
            })
          })
    
        // logging results
       // console.log(quotes);
       // await browser.close();
    
    };
    scrape()
    
    Login or Signup to reply.
  3. The button I want to click is inside a span which is the one that contains the text "more", I think that when I press the button it loads a javascript function to show more content but not asynch

     <span class="ipc-see-more sc-4d3dda93-0 fMZdeF single-page-see-more-button-followed_by">
          <button class="ipc-btn ipc-btn--single-padding ipc-btn--center-align-content ipc-btn--default-height ipc-btn--core-base ipc-btn--theme-base ipc-btn--on-accent2 ipc-text-button ipc-see-more__button" role="button" tabindex="0" aria-disabled="false">
            <span class="ipc-btn__text">
              <span class="ipc-see-more__text">2 more</span>
            </span>
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" class="ipc-icon ipc-icon--expand-more ipc-btn__icon ipc-btn__icon--post" viewBox="0 0 24 24" fill="currentColor" role="presentation">
              <path opacity=".87" fill="none" d="M24 24H0V0h24v24z"></path>
              <path d="M15.88 9.29L12 13.17 8.12 9.29a.996.996 0 1 0-1.41 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59a.996.996 0 0 0 0-1.41c-.39-.38-1.03-.39-1.42 0z"></path>
            </svg>
          </button>
        </span>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search