'Python webscrape CNN, some have results, some returns None
I'm new to web scrape and I tried doing multiple sites but the results aren't the same. This is the basic lines of code I always use:
from bs4 import BeautifulSoup
import requests
url = 'https://edition.cnn.com/world'
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
data = soup.find_all(class_= 'cd__content')
print(data)
for i in data:
print(i.getText())
If I replace the url with https://www.cnn.com/ , the result I receive is empty. They both have the same class 'cd__content'. Can somebody explain me why?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
