HTML-таблица Python только получает первую строку - PullRequest
0 голосов
/ 30 мая 2018

Я пытаюсь проанализировать исторические данные для биткойнов.Вместо 30 в 30 строках, я получаю один день, повторенный 30 раз.

import requests
import urllib.request
from bs4 import BeautifulSoup

url = "https://coinmarketcap.com/currencies/bitcoin/historical-data/"

r = requests.get(url)

html_content = r.text

soup = BeautifulSoup(html_content,"html.parser")

for tr  in soup.find_all('tr')[6]:
   tds = soup.find_all('td')
   print ("date: %s, Open: %s, High:%s,  Low: %s,  Close: %s, Volume: %s, Marketcap: %s\n" % \
     (tds[0].text,tds[1].text,tds[2].text,tds[3].text,tds[4].text, tds[5].text, tds[6].text))

Вот вывод:

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

date: May 29, 2018, Open: 7129.46, High:7526.42,  Low: 7090.68,  Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000

Я должен получить данные для дат, апрель30 - 29 мая

Чего мне не хватает?

...