This is because many websites do not allow web scraping. Before you start working on any website just check for the status code value. The value needs to be 200. Any number other than this means that the website either disallows web scraping or allows partial scraping.
EXAMPLE:
import requests
from bs4 import BeautifulSoup
g=requests.get('https://ca.finance.yahoo.com/q?s=AAPL&ql=0')
g.status_code
OUTPUT: 200