Professional Documents
Culture Documents
Web Scraping
Web Scraping
import pandas as pd
In [42]: tesla_info=tesla.info
tesla_info
'fullTimeEmployees': 99290,
'city': 'Austin',
'state': 'TX',
'companyOfficers': [],
'website': 'https://www.tesla.com',
'maxAge': 1,
'ebitdaMargins': 0.1734,
'profitMargins': 0.102539994,
'grossMargins': 0.25279,
'operatingCashflow': 11496999936,
'revenueGrowth': 0.649,
'operatingMargins': 0.121190004,
'ebitda': 9333000192,
'targetLowPrice': 250,
'recommendationKey': 'hold',
'grossProfits': 13606000000,
'freeCashflow': 4628125184,
'targetMedianPrice': 1035,
'currentPrice': 922.43,
'earningsGrowth': 7.538,
'currentRatio': 1.375,
'returnOnAssets': 0.07135,
'numberOfAnalystOpinions': 36,
'targetMeanPrice': 965.99,
'debtToEquity': 28.192,
'returnOnEquity': 0.20426,
'targetHighPrice': 1480,
'totalCash': 17706999808,
'totalDebt': 8903999488,
'totalRevenue': 53823000576,
'totalCashPerShare': 17.133,
'financialCurrency': 'USD',
'revenuePerShare': 54.587,
'quickRatio': 0.999,
'recommendationMean': 2.6,
'exchange': 'NMS',
'exchangeTimezoneName': 'America/New_York',
'exchangeTimezoneShortName': 'EST',
'isEsgPopulated': False,
'gmtOffSetMilliseconds': '-18000000',
'quoteType': 'EQUITY',
'symbol': 'TSLA',
'messageBoardId': 'finmb_27444752',
'market': 'us_market',
'annualHoldingsTurnover': None,
'enterpriseToRevenue': 16.679,
'beta3Year': None,
'enterpriseToEbitda': 96.185,
'52WeekChange': 0.09723735,
'morningStarRiskRating': None,
'forwardEps': 12.54,
'revenueQuarterlyGrowth': None,
'sharesOutstanding': 1033510016,
'fundInceptionDate': None,
'annualReportExpenseRatio': None,
'totalAssets': None,
'bookValue': 29.225,
'sharesShort': 24057278,
'sharesPercentSharesOut': 0.0233,
'fundFamily': None,
'lastFiscalYearEnd': 1640908800,
'heldPercentInstitutions': 0.4253,
'netIncomeToCommon': 5523999744,
'trailingEps': 4.901,
'lastDividendValue': None,
'SandP52WeekChange': 0.11963892,
'priceToBook': 31.563046,
'heldPercentInsiders': 0.19393998,
'nextFiscalYearEnd': 1703980800,
'yield': None,
'mostRecentQuarter': 1640908800,
'shortRatio': 0.77,
'sharesShortPreviousMonthDate': 1640908800,
'floatShares': 838195343,
'beta': 2.006464,
'enterpriseValue': 897695612928,
'priceHint': 2,
'threeYearAverageReturn': None,
'lastSplitDate': 1598832000,
'lastSplitFactor': '5:1',
'legalType': None,
'lastDividendDate': None,
'morningStarOverallRating': None,
'earningsQuarterlyGrowth': 7.596,
'priceToSalesTrailing12Months': 17.712515,
'dateShortInterest': 1643587200,
'pegRatio': 3.93,
'ytdReturn': None,
'forwardPE': 73.55901,
'lastCapGain': None,
'shortPercentOfFloat': 0.028399998,
'sharesShortPriorMonth': 22471754,
'impliedSharesOutstanding': 0,
'category': None,
'fiveYearAverageReturn': None,
'previousClose': 875.76,
'regularMarketOpen': 900,
'twoHundredDayAverage': 824.8434,
'trailingAnnualDividendYield': 0,
'payoutRatio': 0,
'volume24Hr': None,
'regularMarketDayHigh': 923,
'navPrice': None,
'averageDailyVolume10Day': 22318300,
'regularMarketPreviousClose': 875.76,
'fiftyDayAverage': 989.8474,
'trailingAnnualDividendRate': 0,
'open': 900,
'toCurrency': None,
'averageVolume10days': 22318300,
'expireDate': None,
'algorithm': None,
'dividendRate': None,
'exDividendDate': None,
'circulatingSupply': None,
'startDate': None,
'regularMarketDayLow': 893.3774,
'currency': 'USD',
'trailingPE': 188.2126,
'regularMarketVolume': 19216514,
'lastMarket': None,
'maxSupply': None,
'openInterest': None,
'marketCap': 953340657664,
'volumeAllCurrencies': None,
'strikePrice': None,
'averageVolume': 26157834,
'dayLow': 893.3774,
'ask': 0,
'askSize': 2200,
'volume': 19216514,
'fiftyTwoWeekHigh': 1243.49,
'fromCurrency': None,
'fiveYearAvgDividendYield': None,
'fiftyTwoWeekLow': 539.49,
'bid': 0,
'tradeable': False,
'dividendYield': None,
'bidSize': 1000,
'dayHigh': 923,
'regularMarketPrice': 922.43,
'preMarketPrice': None,
'logo_url': 'https://logo.clearbit.com/tesla.com'}
In [45]: tesla_data.reset_index(inplace=True)
In [46]: tesla_data.head()
Out[46]: index Date Open High Low Close Volume Dividends Stock Splits
In [47]: tesla_revenue.tail()
46 2010-03-31 21
47 2009-12-31
48 2009-09-30 46
49 2009-06-30 27
50 2008-12-31
!pip install requests==2.26.0
In [58]:
!mamba install bs4==4.10.0 -y
import plotly.graph_objects as go
fig.update_layout(showlegend=False,
height=900,
title=stock,
xaxis_rangeslider_visible=True)
fig.show()
"mamba" Ґ
пў«пҐвбп ў
гв॥© Ё«Ё ў
Ґи
Ґ©
Є®¬
¤®©, ЁбЇ®«
塞®© Їа®Ја ¬¬®© Ё«Ё Ї ЄҐв
л¬ д ©«®¬.
"mamba" Ґ
пў«пҐвбп ў
гв॥© Ё«Ё ў
Ґи
Ґ©
Є®¬
¤®©, ЁбЇ®«
塞®© Їа®Ја ¬¬®© Ё«Ё Ї ЄҐв
л¬ д ©«®¬.
import requests
tesla_table_index = index
col = row.find_all("td")
if (col !=[]):
date = col[0].text
In [37]: tesla_revenue.tail()
46 2010-03-31 21
47 2009-12-31
48 2009-09-30 46
49 2009-06-30 27
50 2008-12-31
In [5]: GameStop_info=GameStop.info
GameStop_info
'fullTimeEmployees': 12000,
'city': 'Grapevine',
'state': 'TX',
'companyOfficers': [],
'website': 'https://www.gamestop.com',
'maxAge': 1,
'ebitdaMargins': -0.01626,
'profitMargins': -0.026080001,
'grossMargins': 0.24123,
'operatingCashflow': -159200000,
'revenueGrowth': 0.291,
'operatingMargins': -0.02864,
'ebitda': -95600000,
'targetLowPrice': 23,
'recommendationKey': 'underperform',
'grossProfits': 1259500000,
'freeCashflow': -168137504,
'targetMedianPrice': 45,
'currentPrice': 126.16,
'earningsGrowth': None,
'currentRatio': 1.9,
'returnOnAssets': -0.03308,
'numberOfAnalystOpinions': 3,
'targetMeanPrice': 56,
'debtToEquity': 38.053,
'returnOnEquity': -0.14709,
'targetHighPrice': 100,
'totalCash': 1412999936,
'totalDebt': 667800000,
'totalRevenue': 5878900224,
'totalCashPerShare': 18.604,
'financialCurrency': 'USD',
'revenuePerShare': 84.044,
'quickRatio': 1.079,
'recommendationMean': 4,
'exchange': 'NYQ',
'exchangeTimezoneName': 'America/New_York',
'exchangeTimezoneShortName': 'EST',
'isEsgPopulated': False,
'gmtOffSetMilliseconds': '-18000000',
'quoteType': 'EQUITY',
'symbol': 'GME',
'messageBoardId': 'finmb_1342560',
'market': 'us_market',
'annualHoldingsTurnover': None,
'enterpriseToRevenue': 1.386,
'beta3Year': None,
'enterpriseToEbitda': -85.229,
'52WeekChange': 1.5487592,
'morningStarRiskRating': None,
'forwardEps': -0.8,
'revenueQuarterlyGrowth': None,
'sharesOutstanding': 76350800,
'fundInceptionDate': None,
'annualReportExpenseRatio': None,
'totalAssets': None,
'bookValue': 23.244,
'sharesShort': 10998384,
'sharesPercentSharesOut': 0.1441,
'fundFamily': None,
'lastFiscalYearEnd': 1611964800,
'heldPercentInstitutions': 0.28236,
'netIncomeToCommon': -153500000,
'trailingEps': -2.194,
'lastDividendValue': 0.38,
'SandP52WeekChange': 0.11963892,
'priceToBook': 5.4276376,
'heldPercentInsiders': 0.18014999,
'nextFiscalYearEnd': 1675036800,
'yield': None,
'mostRecentQuarter': 1635552000,
'shortRatio': 2.68,
'sharesShortPreviousMonthDate': 1640908800,
'floatShares': 62843955,
'beta': -1.633018,
'enterpriseValue': 8147876864,
'priceHint': 2,
'threeYearAverageReturn': None,
'lastSplitDate': 1174262400,
'lastSplitFactor': '2:1',
'legalType': None,
'lastDividendDate': 1552521600,
'morningStarOverallRating': None,
'earningsQuarterlyGrowth': None,
'priceToSalesTrailing12Months': 1.6384726,
'dateShortInterest': 1643587200,
'pegRatio': 1.51,
'ytdReturn': None,
'forwardPE': -157.7,
'lastCapGain': None,
'shortPercentOfFloat': 0.23709999,
'sharesShortPriorMonth': 8449995,
'impliedSharesOutstanding': 0,
'category': None,
'fiveYearAverageReturn': None,
'previousClose': 117.09,
'regularMarketOpen': 120.96,
'twoHundredDayAverage': 177.7728,
'trailingAnnualDividendYield': 0,
'payoutRatio': 0,
'volume24Hr': None,
'regularMarketDayHigh': 127.2299,
'navPrice': None,
'averageDailyVolume10Day': 3070940,
'regularMarketPreviousClose': 117.09,
'fiftyDayAverage': 131.8536,
'trailingAnnualDividendRate': 0,
'open': 120.96,
'toCurrency': None,
'averageVolume10days': 3070940,
'expireDate': None,
'algorithm': None,
'dividendRate': None,
'exDividendDate': 1552521600,
'circulatingSupply': None,
'startDate': None,
'regularMarketDayLow': 119.26,
'currency': 'USD',
'regularMarketVolume': 1950844,
'lastMarket': None,
'maxSupply': None,
'openInterest': None,
'marketCap': 9632416768,
'volumeAllCurrencies': None,
'strikePrice': None,
'averageVolume': 3168454,
'dayLow': 119.26,
'ask': 0,
'askSize': 1200,
'volume': 1950844,
'fiftyTwoWeekHigh': 348.5,
'fromCurrency': None,
'fiveYearAvgDividendYield': None,
'fiftyTwoWeekLow': 38.5,
'bid': 0,
'tradeable': False,
'dividendYield': None,
'bidSize': 1100,
'dayHigh': 127.2299,
'regularMarketPrice': 126.16,
'preMarketPrice': None,
'logo_url': 'https://logo.clearbit.com/gamestop.com'}
In [6]: GameStop_data = GameStop.history(period="max")
In [7]: GameStop_data.reset_index(inplace=True)
In [8]: GameStop_data.head()
2002-02-
0 6.480513 6.773399 6.413183 6.766666 19054000 0.0 0.0
13
2002-02-
1 6.850829 6.864295 6.682504 6.733002 2755400 0.0 0.0
14
2002-02-
2 6.733001 6.749833 6.632006 6.699336 2097400 0.0 0.0
15
2002-02-
3 6.665672 6.665672 6.312190 6.430017 1852600 0.0 0.0
19
2002-02-
4 6.463682 6.648839 6.413184 6.648839 1723200 0.0 0.0
20
GameStop_table_index = index
col = row.find_all("td")
if (col !=[]):
date = col[0].text
In [20]: GameStop_revenue.tail()
63 2006-01-31 1667
64 2005-10-31 534
65 2005-07-31 416
66 2005-04-30 475
67 2005-01-31 709
In [52]: tesla_url = "https://www.macrotrends.net/stocks/charts/TSLA/tesla/revenue
tesla_data = requests.get(tesla_url).text
tesla_table_index = index
col = row.find_all("td")
if (col !=[]):
date = col[0].text
In [55]: tesla_revenue.tail()
46 2010-03-31 21
47 2009-12-31
48 2009-09-30 46
49 2009-06-30 27
50 2008-12-31
import requests
import plotly.graph_objects as go
In [62]: tesla_price_data.head()
Date
In [63]: tesla_price_data.reset_index(inplace=True)
Out[64]: <AxesSubplot:xlabel='Date'>
tesla_table_index = index
col = row.find_all("td")
if (col !=[]):
date = col[0].text
In [70]: tesla_revenue.tail()
46 2010-03-31 21
47 2009-12-31
48 2009-09-30 46
49 2009-06-30 27
50 2008-12-31
import pandas as pd
revenue_data.reset_index(inplace=True)
shared_xaxes=True,
fig.add_trace(go.Scatter(
x=pd.to_datetime(stock_data_specific.Date, infer_datetime_format=
y=stock_data_specific.Close.astype("float"), name="Share Price")
fig.add_trace(go.Scatter(x=pd.to_datetime(revenue_data_specific.Date
y=revenue_data_specific.Volume.astype("float
name="Volume"), row=2, col=1)
fig.update_layout(showlegend=False,
height=900,
title=stock,
xaxis_rangeslider_visible=True)
fig.show()
import pandas as pd
revenue_data.reset_index(inplace=True)
shared_xaxes=True,
fig.add_trace(go.Scatter(
x=pd.to_datetime(stock_data_specific.Date, infer_datetime_format=
y=stock_data_specific.Close.astype("float"), name="Share Price")
fig.add_trace(go.Scatter(x=pd.to_datetime(revenue_data_specific.Date
y=revenue_data_specific.Volume.astype("float
name="Volume"), row=2, col=1)
fig.update_layout(showlegend=False,
height=900,
title=stock,
xaxis_rangeslider_visible=True)
fig.show()
In [ ]: