i'm learning how to scrape, then I'm not really advanced. I wuold scrape from bloomberg the company description. For instance from this page (https://www.bloomberg.com/research/stocks/private/snapshot.asp?privcapId=320105)
I would like to scrape
<p id="bDescTeaser" itemprop="description">Fiat Chrysler Automobiles N.V., ...</p>
My Script :
from urllib.request import Request, urlopen
from bs4 import BeautifulSoup
html= 'https://www.bloomberg.com/research/stocks/private/snapshot.asp?
privcapId=32010'
page = urlopen(html)
data = BeautifulSoup(page, 'html.parser')
text = data.find('p',id="bDescTeaser",itemprop=" ")
print(text.get_text))
If I try to run the program I get,
AttributeError: 'NoneType' object has no attribute 'get_text'
Is this a problem with my code or with this specific webapge?
In your solution Bloomberg blocks your request. Because it thinks you are a bot. You should use requests library and send user agent as header. You will get your expected output this way.
import requests
from bs4 import BeautifulSoup
header = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0'}
request = requests.get('https://www.bloomberg.com/research/stocks/private/snapshot.asp?privcapId=320105',headers=header)
soup = BeautifulSoup(request.text, 'html.parser')
text = soup.find('p',id="bDescTeaser")
print(text.get_text())