Quote:This is the Html element which is present in the website that i want to parseThis is to see if i am getting the right element from the page but i don't think i am getting the right element from the page.
"""
<span data-bind="text: title">BTC Markets</span>
<td class="order-type">
<td class="order-type">
<span data-bind="text: displayChange(), css: {'color-green': change() > 0, 'color-red': change() < 0, '': change() == 0}" class="color-green">0.8</span>
<span data-bind="css: { 'icon-arrow': change() > 0, 'icon-arrow-down': change() < 0, '': change() == 0 }" class="icon-arrow"></span>
<span data-bind="text: displayChange(), css: {'color-green': change() > 0, 'color-red': change() < 0, '': change() == 0}" class="color-red">-7.5</span>
</td>
"""
I only need to check how many of the elements are in red-color and green-color
So first of all i parse the website into HTML
Than i call the span tag which i want to read (here i think i have done something wrong since it doesn't return anything except the value None)
We can identify the red color because it has a -7.5 and the green color has no -
My objective is to find out how many are in green and red and give me the total of red and a total of green
Please help your brother out![]()
from bs4 import BeautifulSoup import requests def stock(): request = requests.get("https://global.bittrex.com/home/markets") content = request.content soup = BeautifulSoup(content, "html.parser") print(soup.prettify()) if __name__ == '__main__': stock() Output is uploaded on pastebin https://pastebin.com/VvrLaBNR
from bs4 import BeautifulSoup import requests request = requests.get("https://global.bittrex.com/home/markets") content = request.content soup = BeautifulSoup(content, "html.parser") green_element = soup.find("span",{"class":"color-green"}) red_element = soup.find("span",{"class":"color-red"}) print('Green: ',green_element) #print the total number of green coins like "Green : 125" print('Red: ',red_element)