From 059a4de04f1a964323c8560b9bac27ccc6d3b177 Mon Sep 17 00:00:00 2001 From: newt Date: Wed, 9 Oct 2024 18:02:33 +0100 Subject: [PATCH] twitch channel revenue estimation --- python/data science/twitchsubs.csv | 201 +++++++++++++++++++++++++++++ python/data science/twitchsubs.py | 65 ++++++++++ readme.md | 1 + 3 files changed, 267 insertions(+) create mode 100644 python/data science/twitchsubs.csv create mode 100644 python/data science/twitchsubs.py diff --git a/python/data science/twitchsubs.csv b/python/data science/twitchsubs.csv new file mode 100644 index 0000000..6690b03 --- /dev/null +++ b/python/data science/twitchsubs.csv @@ -0,0 +1,201 @@ +,channelName,totalSubs,totalCostOfSubs,twitchCuts,totalEarnings +1,RanbooLive,114322.0,407894.94,203289.94,255807.5 +2,xQcOW,75139.0,125059.43000000001,62176.93000000001,147895.0 +3,NICKMERCS,57700.0,152240.45,75327.95000000001,111122.5 +4,HasanAbi,55035.0,98657.06000000001,49009.56000000001,92175.0 +5,Gaules,,,, +6,AdinRoss,50336.0,118728.38,59193.380000000005,98737.5 +7,ibai,45868.0,86787.28,43247.28,113835.0 +8,auronplay,45048.0,104293.63,51931.130000000005,102075.0 +9,Sintica,,,, +10,summit1g,37416.0,97974.54,48624.53999999999,77382.5 +11,casimito,31117.0,26008.17,12968.169999999998,68585.0 +12,MontanaBlack88,29022.0,67276.32,33526.32000000001,66227.5 +13,Repullze,,,, +14,Trainwreckstv,26336.0,79507.26,39592.259999999995,57235.0 +15,Philza,,,, +16,chowh1,23925.0,96620.56,48013.06,58110.0 +17,ludwig,,,, +18,LVNDMARK,23681.0,67420.27,33157.770000000004,56697.5 +19,juansguarnizo,23228.0,58643.91,29198.910000000003,51982.5 +20,Amouranth,22648.0,81019.78000000001,40312.28000000001,52667.5 +21,Odablock,,,, +22,Anastasia_Rose_Official,,,, +23,MOONMOON,21247.0,57008.29,27768.29,51417.5 +24,Sykkuno,21221.0,78462.95000000001,38932.95000000001,50885.0 +25,alanzoka,20862.0,16598.640000000003,8188.640000000003,46437.5 +26,moistcr1tikal,20171.0,59665.64000000001,29538.140000000007,47617.5 +27,Mizkif,20121.0,44622.18,22192.18,39840.0 +28,PaymoneyWubby,20000.0,71592.23000000001,35454.73000000001,47950.0 +29,iiTzTimmy,19913.0,64737.439999999995,32194.939999999995,47077.5 +30,AdmiralBahroo,19484.0,47963.520000000004,23683.520000000004,37547.5 +31,LIRIK,19105.0,37611.05,18706.050000000003,42947.5 +32,TheRealKnossi,18350.0,44991.15,22401.15,41780.0 +33,richwcampbell,18315.0,72018.12,35813.119999999995,44652.5 +34,Pestily,17857.0,80125.3,39460.3,47625.0 +35,JLTomy,17391.0,49641.950000000004,24709.450000000004,39565.0 +36,Locklear,17327.0,58711.4,29118.9,41695.0 +37,BobbyPoffGaming,,,, +38,VooDooSh,16978.0,86177.05000000002,42752.05000000002,43542.5 +39,MckyTV,16962.0,51698.200000000004,25703.200000000004,40060.0 +40,tommyinnit,16774.0,40335.450000000004,20082.950000000004,32392.5 +41,LuckyChamu,,,, +42,TimTheTatman,16658.0,45007.03999999999,22377.039999999994,37942.5 +43,Zoomaa,,,, +44,RATIRL,16326.0,58901.01,28901.010000000002,40712.5 +45,LosPollosTV,16197.0,54406.64,27119.14,37705.0 +46,BruceGreene,,,, +47,Kamet0,15702.0,40260.38,20042.879999999997,35900.0 +48,Tubbo,15578.0,65685.61,32683.11,39605.0 +49,alexelcapo,15500.0,19126.930000000004,9536.930000000004,34825.0 +50,Jerma985,15261.0,33834.01,16804.010000000002,34757.5 +51,GRONKH,15062.0,44627.149999999994,22229.649999999994,34997.5 +52,scump,15009.0,56338.27,28058.269999999997,35410.0 +53,Rubius,14812.0,30555.460000000003,15155.460000000003,33820.0 +54,WELOVEGAMES,,,, +55,NoWay4u_Sir,14613.0,23085.920000000002,11418.420000000002,33367.5 +56,loltyler1,14604.0,26793.05,13285.55,33295.0 +57,buddha,14522.0,51802.63,25787.629999999997,34017.5 +58,ZeratoR,14502.0,46808.46000000001,23273.460000000006,33747.5 +59,GernaderJake,,,, +60,Elraenn,14319.0,27696.25,13731.25,32882.5 +61,CohhCarnage,14280.0,54026.46000000001,26753.960000000006,35877.5 +62,Dhalucard,14165.0,56116.170000000006,27841.170000000006,34907.5 +63,Cellbit,14129.0,22784.54,11362.04,31717.5 +64,Asmongold,13901.0,35161.560000000005,17451.560000000005,32227.5 +65,BruceDropEmOff,,,, +66,elxokas,,,, +67,IlloJuan,,,, +68,Ramee,,,, +69,WilburSoot,13384.0,46532.850000000006,23187.850000000006,31102.5 +70,RatedEpicz,13246.0,48165.71000000001,23938.210000000006,31527.5 +71,eliasn97,13212.0,23423.570000000003,11671.070000000003,29975.0 +72,wtcN,13107.0,26817.920000000006,13295.420000000006,30077.5 +73,TSM_ImperialHal,12655.0,41339.46,20521.96,29725.0 +74,exzachtt,,,, +75,ElMariana,12447.0,25579.03,12749.029999999999,27610.0 +76,Tumblurr,12409.0,22470.910000000003,11165.910000000003,28527.5 +77,ShahZaM,12347.0,29183.42,14468.419999999998,28640.0 +78,Trymacs,12273.0,14955.39,7452.889999999999,27092.5 +79,Tectone,,,, +80,chessbrah,,,, +81,Lysium,,,, +82,Shotz,11728.0,54672.51,27177.510000000002,29200.0 +83,DarioMocciaTwitch,11673.0,14461.78,7176.780000000001,26202.5 +84,TeePee,11508.0,40383.83,19888.83,28110.0 +85,Ailenax,,,, +86,AussieAntics,,,, +87,Jelty,11281.0,23383.7,11641.2,25307.5 +88,Aydan,11152.0,45151.090000000004,22453.590000000004,26920.0 +89,sodapoppin,10988.0,24732.28,12252.279999999999,25097.5 +90,forsen,10988.0,28190.88,13980.880000000001,25152.5 +91,Maximilian_DOOD,10966.0,34722.69,17257.690000000002,25445.0 +92,Swagg,10951.0,41583.5,20703.5,25805.0 +93,Zerkaa,,,, +94,PENTA,10711.0,43194.31,21524.309999999998,25752.5 +95,shroud,10539.0,22785.58,11303.080000000002,23710.0 +96,Punz,,,, +97,PietSmiet,10346.0,34238.090000000004,17018.090000000004,24775.0 +98,loud_coringa,10273.0,19825.420000000002,9887.920000000002,22910.0 +99,jbzzed,10254.0,40585.26,20175.260000000002,25045.0 +100,Staryuuki,10240.0,48295.19,24015.190000000002,25737.5 +101,ShoXx__,,,, +102,TheGrefg,10094.0,17300.52,8623.02,22687.5 +103,SmallAnt,,,, +104,AnEternalEnigma,,,, +105,KYR_SP33DY,9986.0,34368.82,17031.32,24012.5 +106,CriticalRole,9850.0,24556.89,12221.89,21622.5 +107,Sapnap,9782.0,39645.89000000001,19768.390000000007,23117.5 +108,fps_shaka,9773.0,9461.77,4686.77,15352.5 +109,BarbarousKing,9702.0,36730.5,18143.0,23797.5 +110,mang0,9688.0,33983.79,16888.79,22920.0 +111,Sweatcicle,,,, +112,Kyle,,,, +113,GsxrClyde,,,, +114,ProblemWright,,,, +115,CDNThe3rd,9326.0,36245.0,17970.0,22775.0 +116,Moonryde,,,, +117,Ponce,9210.0,26992.230000000003,13427.230000000003,21187.5 +118,ZanoXVII,9200.0,6317.54,3142.54,20330.0 +119,Shlorox,9104.0,30790.82,15265.82,21867.5 +120,GTAWiseGuy,,,, +121,ELoTRiX,9075.0,32711.510000000002,16231.510000000002,21917.5 +122,YoDa,9003.0,8253.67,4108.67,20050.0 +123,dmajszi,,,, +124,GrandPOObear,8899.0,39816.310000000005,19818.810000000005,21982.5 +125,RayNarvaezJr,8884.0,37642.58,18445.08,23170.0 +126,Whippy,,,, +127,AnnieFuchsia,,,, +128,MAZA4KST,,,, +129,Agraelus,8601.0,38918.24,19373.239999999998,20495.0 +130,knekro,8565.0,13029.53,6472.030000000001,19442.5 +131,IceManIsaac,,,, +132,Kiva,,,, +133,Gotaga,8461.0,26732.61,13295.11,19797.5 +134,KendineMuzisyen,8452.0,11358.210000000001,5623.210000000001,18940.0 +135,DavidLafargeOFF,,,, +136,RonnieRadke,,,, +137,KarmikKoala,8264.0,42784.71,21092.21,21820.0 +138,AvoidingThePuddle,8228.0,22536.750000000004,11179.250000000004,19110.0 +139,DiazBiffle,,,, +140,Reborn_Live,8204.0,38675.24,19125.239999999998,21737.5 +141,mistermv,8174.0,19982.280000000002,9879.780000000002,18910.0 +142,MYM_ALKAPONE,8160.0,13233.94,6581.4400000000005,18285.0 +143,TobiasFate,8144.0,20994.38,10406.880000000001,19100.0 +144,Timmac,,,, +145,Tfue,8009.0,23124.820000000003,11487.320000000003,18502.5 +146,Kitboga,7979.0,27207.32,13497.32,18992.5 +147,TheNicoleT,,,, +148,IamCristinini,7909.0,28928.190000000002,14383.190000000002,19140.0 +149,Papaplatte,7875.0,10025.39,4985.389999999999,17780.0 +150,melharucos,7820.0,43778.520000000004,21341.020000000004,22567.5 +151,Foolish_Gamers,7817.0,32530.76,16193.259999999998,18800.0 +152,cloakzy,7745.0,26792.460000000003,13322.460000000003,17955.0 +153,Snip3down,,,, +154,Castro_1021,7680.0,20310.190000000002,10095.190000000002,17497.5 +155,Amar,,,, +156,CPentagon,,,, +157,Ninja,7602.0,20370.23,10120.23,17575.0 +158,AnniTheDuck,7552.0,27461.27,13648.77,18222.5 +159,Quin69,7541.0,27188.57,13403.57,18675.0 +160,Atrioc,,,, +161,JesusAVGN,7517.0,36308.85,18056.35,18380.0 +162,fuslie,,,, +163,capturesca,,,, +164,sweetdreams,7403.0,32083.11,15928.11,18395.0 +165,elded,7398.0,19009.29,9424.29,17132.5 +166,RvNxMango,,,, +167,Altair,7293.0,30255.3,14795.3,19135.0 +168,JASONR,7291.0,31982.190000000002,15894.690000000002,18045.0 +169,Smzinho,7142.0,6741.840000000001,3346.840000000001,15865.0 +170,FolagorLives,7130.0,18832.49,9387.490000000002,17892.5 +171,Radlerauge,,,, +172,Mystixx,,,, +173,Dropped,,,, +174,Sequisha,,,, +175,Putupau,6981.0,15199.86,7569.860000000001,15842.5 +176,LuluLuvely,,,, +177,Sardoche,6818.0,15524.96,7702.459999999999,15580.0 +178,POW3Rtv,6784.0,7974.63,3949.63,15152.5 +179,xRohat,,,, +180,BabyBouge,,,, +181,SypherPK,6700.0,20929.13,10389.130000000001,16547.5 +182,pqueen,,,, +183,pokimane,6607.0,23795.609999999997,11690.609999999997,16150.0 +184,Elajjaz,6603.0,20745.18,10280.18,15652.5 +185,bt0tv,6597.0,17245.61,8600.61,15140.0 +186,sleepy,,,, +187,Perxitaa,6577.0,25818.399999999998,12878.399999999998,15752.5 +188,HellYeahPlay,,,, +189,FrostPrime_,,,, +190,HusKerrs,6567.0,24337.15,12102.150000000001,15712.5 +191,Domingo,6566.0,18433.86,9163.86,14927.5 +192,TrilluXe,6565.0,33259.35,16554.35,16705.0 +193,stylishnoob4,6522.0,10648.88,5303.879999999999,14672.5 +194,NeskWgA,,,, +195,RoyalPhunk,6404.0,26293.970000000005,13056.470000000005,15752.5 +196,sargentocharli,,,, +197,MissJuneDJ,,,, +198,Spofie,,,, +199,firedancer,,,, +200,elwycco,6267.0,30529.84,15194.84,15437.5 diff --git a/python/data science/twitchsubs.py b/python/data science/twitchsubs.py new file mode 100644 index 0000000..ed81131 --- /dev/null +++ b/python/data science/twitchsubs.py @@ -0,0 +1,65 @@ +import requests +import pandas as pd +from bs4 import BeautifulSoup +import time +import os + +TIER1PRICE = 4.99 +TIER2PRICE = 9.99 +TIER3PRICE = 24.99 +TIER1EARNING = 2.50 +TIER2EARNING = 5 +TIER3EARNING = 15 + +headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'} + +def getRows(page): + time.sleep(1) + response = requests.get('https://twitchtracker.com/subscribers?page=%i' % (page), headers=headers) + soup = BeautifulSoup(response.content, 'html.parser') + trs = soup.select('#channels tr') + if len(trs) > 0: + del trs[0] + print('Processed page %i' % (page)) + return trs + +howMany = int(input('How many pages would you like to scrape? There are 20 streamers a page.\n')) +data = [] + +for i in range(howMany): + trs = getRows(i + 1) + if len(trs) > 0: + # Remove dividers from the table + for count, tr in enumerate(trs, 1): + if count % 11 == 0: + i = trs.index(tr) + del trs[i] + for row in trs: + frame = {} + tds = row.select('td') + # Filters out rows without full stas + fullStats = True + if len(tds) != 11: + fullStats = False + for td in tds: + if td.text.strip().__contains__('?'): + fullStats = False + frame['channelName'] = tds[3].text.strip() + # Fill in the stats if they are full + if fullStats == True: + tier1 = int(tds[8].text) + tier2 = int(tds[9].text) + tier3 = int(tds[10].text) + prime = int(tds[6].text) + totalCost = (tier1 * TIER1PRICE) + (tier2 * TIER2PRICE) + (tier3 * TIER3PRICE) + totalEarnings = (tier1 * TIER1EARNING) + (tier2 * TIER2EARNING) + (tier3 * TIER3EARNING) + frame['totalSubs'] = int(tds[4].text) + frame['totalCostOfSubs'] = totalCost + frame['twitchCuts'] = totalCost - totalEarnings + frame['totalEarnings'] = totalEarnings + (prime * TIER1EARNING) + # Append + data.append(frame) + +df = pd.DataFrame(data, index=None) +df.index += 1 +df.to_csv(os.path.dirname(os.path.realpath(__file__)) + '/twitchsubs.csv') diff --git a/readme.md b/readme.md index 06cd797..0b6e5b4 100644 --- a/readme.md +++ b/readme.md @@ -12,6 +12,7 @@ - [Data Science](python/data%20science) - [Fake Jobs Scraper](python/data%20science/fakejobs.py) - [Country Population vs Active Facebook Users in the Country](python/data%20science/facebook.py) + - [Estimated Revenue for the top Twitch channels](python/data%20science/twitchsubs.py) - [ngrams](python/data%20science/ngrams) - [Comparison](python/data%20science/ngrams/comparison/comparison.py) - [Popularity](python/data%20science/ngrams/popularity/popularity.py)