extract text from html using python

Viewed 2662

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)
1 Answers
Related