-
Notifications
You must be signed in to change notification settings - Fork 392
/
pull_data.py
36 lines (32 loc) · 1.63 KB
/
pull_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from bs4 import BeautifulSoup
import requests
import csv
import pandas as pd
names=[]
prices=[]
changes=[]
percentChanges=[]
marketCaps=[]
totalVolumes=[]
circulatingSupplys=[]
for i in range(0,11):
CryptoCurrenciesUrl = "https://in.finance.yahoo.com/most-active?offset="+str(i)+"&count=100"
r= requests.get(CryptoCurrenciesUrl)
data=r.text
soup=BeautifulSoup(data, features = 'lmxl')
for listing in soup.find_all('tr', attrs={'class':'SimpleDataTableRow'}):
for name in listing.find_all('td', attrs={'aria-label':'Name'}):
names.append(name.text)
for price in listing.find_all('td', attrs={'aria-label':'Price (intraday)'}):
prices.append(price.find('span').text)
for change in listing.find_all('td', attrs={'aria-label':'Change'}):
changes.append(change.text)
for percentChange in listing.find_all('td', attrs={'aria-label':'% change'}):
percentChanges.append(percentChange.text)
for marketCap in listing.find_all('td', attrs={'aria-label':'Market cap'}):
marketCaps.append(marketCap.text)
for totalVolume in listing.find_all('td', attrs={'aria-label':'Avg vol (3-month)'}):
totalVolumes.append(totalVolume.text)
for circulatingSupply in listing.find_all('td', attrs={'aria-label':'Volume'}):
circulatingSupplys.append(circulatingSupply.text)
pd.DataFrame({"Names": names, "Prices": prices, "Change": changes, "% Change": percentChanges, "Market Cap": marketCaps, "Average Volume": totalVolumes,"Volume":circulatingSupplys})