Q:

extract text from html using python

hope anyone can help me. I am fairly new to python, but I want to scrape data from a site, which unfortunately needs an account. Although i am not able to extract the date (i.e. 2017-06-01). 
<li class="latest-value-item">
  <div class="latest-value-label">Date</div>
  <div class="latest-value">2017-06-01</div>
</li>
<li class="latest-value-item">
  <div class="latest-value-label">Index</div>
  <div class="latest-value">1430</div>
</li>

THis is my code:
import urllib3 
import urllib.request
from bs4 import BeautifulSoup
import pandas as pd
import requests
import csv
from datetime import datetime

url = 'https://www.quandl.com/data/LLOYDS/BCI-Baltic-Capesize-Index'
r = requests.get(url)
soup = BeautifulSoup(r.text, 'lxml')

Baltic_Indices = []
New_Value = []

#new = soup.find_all('div', attrs={'class':'latest-value'}).get_text()
date = soup.find_all(class_="latest value")
text1 = date.text

print(text1)

A:

date = soup.find_all(class_="latest value")
You are using the wrong CSS class name ('latest value' != 'latest-value')
 print(soup.find_all(attrs={'class': 'latest-value'}))
 # [<div class="latest-value">2017-06-01</div>, <div class="latest-value">1430</div>]

 for element in soup.find_all(attrs={'class': 'latest-value'}):
     print(element.text)
 # 2017-06-01
 # 1430

I prefer to use attrs kwarg but your method works as well (given the correct CSS class name)
 for element in soup.find_all(class_='latest-value'):
     print(element.text)
 # 2017-06-01
 # 1430

