Skip to content
Advertisement

bs4 p tags returning as None

JavaScript

// scraping link from title, then opening that link and trying to scrape the whole article, very new to this so I don’t know what to do!

JavaScript

Advertisement

Answer

On some pages the <p> tags are not under an <article>, and therefor is returning None. Instead, to scrape all the paragraphs (and <li> tags if they exist) use the following CSS Selector: .entry-content > p, .entry-content li.

To use a CSS Selector, use the .select() method instead of .find_all().


In your code example:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement