Solution Review: Scrape PayPal FAQs Using Selenium and XPath

Explore the solution for scraping FAQs.

We'll cover the following

Solution approach

  • To scrape the questions, we will start by retrieving the elements of the topics from the sidebar.

  • Once we have obtained these elements, we will proceed to click each one and locate the paths of the questions to extract them.

  • A challenge that arises during web scraping with Selenium is handling invisible items. Unlike visible elements, dealing with hidden elements requires a different approach.

    • For instance, if we try to retrieve the text using the .text method, it will return empty values. Similarly, attempting to click such elements using the .click() method will result in an exception. To overcome this issue, we will employ alternative techniques.

    • Instead of using the .text method, we will utilize the .get_attribute("innerHTML") method to extract the desired content from hidden elements. Similarly, instead of directly using the .click() method, we will rely on the driver.execute_script('arguments[0].click()', element) approach to interact with these elements successfully.

Get hands-on with 1200+ tech skills courses.