No errors just not printing the results. it is supposed to print out headlines from the url. the script runs but returns nothing whilst parsing for balancedheadlines. i can swap the tag i look for to p and return data but i believe i am no passing through the tags correctly to retrieve just the headlines.
import requests
from bs4 import BeautifulSoup
url = 'http://www.nytimes.com'
r = requests.get(url)
soup = BeautifulSoup(r.text, 'lxml')
for ap in soup.find_all('h2', attrs = {"class" : "balancedheader"}):
if ap.a:
print(ap.a.text.replace(".n/", " "))
else:
print(ap.strip)
h2tag with thebalancedheaderclass present in the DOM.soup.find_all('h2', attrs = {"class" : "balancedheader"}) == []. Because its an empty list your loop that is supposed to run for every item in the list, does nothing.