I am new to python and html. I am trying to get the number of comments from a page using queries and BeautifulSoup.
In this example, I am trying to get the number 226. Here is the code that I see when I check the page in Chrome:
<a title="Go to the comments page" class="article__comments-counts" href="http://www.theglobeandmail.com/opinion/will-kevin-oleary-be-stopped/article33519766/comments/"> <span class="civil-comment-count" data-site-id="globeandmail" data-id="33519766" data-language="en"> 226 </span> Comments </a>
When I request text from a URL, I can find the code, but there is no content between the span tags, no 226. Here is my code:
import requests, bs4 url = 'http://www.theglobeandmail.com/opinion/will-kevin-oleary-be-stopped/article33519766/' r = requests.get() soup = bs4.BeautifulSoup(r.text, 'html.parser') span = soup.find('span', class_='civil-comment-count')
He returns this, as above, but not 226.
<span class="civil-comment-count" data-id="33519766" data-language="en" data-site-id="globeandmail"> </span>
I do not understand why the meaning does not appear. Thank you in advance for any help.
source share