I am trying to extract the text from a class that appears within (and after) an tag like so:
from bs4 import BeautifulSoup
html = """<div class="wisbb_teamA">
<a href="http://www.example.com/eg1" class="wisbb_name">Phillies</a>
</div>"""
soup = BeautifulSoup(html,"lxml")
for div in soup.findAll('div', attrs={'class':'wisbb_teamA'}):
print(div.find('a').contents[0])
This will return the following:
Phillies
This is correct, but when I try to extract from the actual page, I get the following:
TypeError: object of type 'Response' has no len()
The page is at
https://www.foxsports.com/mlb/scores?season=2019&date=2019-09-23
And I have used the following:
import requests
from bs4 import BeautifulSoup
url = requests.get("https://www.foxsports.com/mlb/scores?season=2019&date=2019-09-23")
soup = BeautifulSoup(url,'lxml')
for div in soup.findAll('div', attrs={'class':'wisbb_teamA'}):
print(div.find('a').contents[0])
Thank you.