-
Notifications
You must be signed in to change notification settings - Fork 2
/
overwatchGameScraper.py
40 lines (29 loc) · 872 Bytes
/
overwatchGameScraper.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
37
38
39
40
from bs4 import BeautifulSoup
import requests
def pullOverwatchVideo(GAMERTAG):
DOMAIN = 'http://xboxdvr.com'
URL = DOMAIN + '/gamer/'+ GAMERTAG +'/videos'
r = requests.get(URL)
html = r.text
soup = BeautifulSoup(html, 'html.parser')
a = soup.find_all('div', {'class': 'vid-card'})
clips = []
i = 0
for vidcard in a:
if 'Overwatch' in vidcard.find_all('div', {'class':'top-row'})[0].a.text:
NEXTPAGE = vidcard.find_all('div', {'class':'content-row'})[0].find('a')['href']
r = requests.get(DOMAIN+NEXTPAGE)
html = r.text
cup = BeautifulSoup(html, 'html.parser')
VIDEO = cup.find('a', {'aria-labeledby':'#itemlabel5'})['href']
clips.append(VIDEO)
i += 1
if i > 10:
break
else:
continue
return list(set(clips))
if __name__ == '__main__':
import sys
GAMERTAG = sys.argv[1]
print(pullOverwatchVideo(GAMERTAG))