What version of python are you running?
If run stock() function alone do it return the result.
Just to make the same error.
If run stock() function alone do it return the result.
from bs4 import BeautifulSoup import requests import time def stock(): requestbtc = requests.get("https://bitscreener.com/coins/bitcoin") requestseth = requests.get("https://bitscreener.com/coins/ethereum") content1 = requestbtc.content content2 = requestseth.content soup1 = BeautifulSoup(content1,"html.parser") soup2 = BeautifulSoup(content2,"html.parser") element1 = soup1.find('div',{"class":"header-price-container"}) btc = element1.text.strip().replace('\n',' \t ') element2 = soup2.find('div',{"class":"header-price-container"}) eth = element2.text.strip().replace('\n',' \t ') return btc, eth print(stock())
Output:('$9,071.34 \t \t \t -$106.24\xa0 \t (-1.16%)', '$205.60 \t \t \t -$1.8007\xa0 \t (-0.87%)')
The error indicate that it return None,also same what BS return if do not find the tag.Just to make the same error.
def stock(): return None >>> btc, eth = stock() Traceback (most recent call last): File "<interactive input>", line 1, in <module> TypeError: cannot unpack non-iterable NoneType object