-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsquads.py
25 lines (20 loc) · 812 Bytes
/
squads.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
from database_helpers import (
sql_connect,
get_users,
romans
)
from pyquery import PyQuery as pq
def get_squads(user):
urls = get_squad_urls(user)
for url in urls:
page = pq(url)
units = page('.collection-char').items()
for unit in units:
unit_name = unit.find('a.char-portrait-full-link').attr('href').split('/')[-2]
unit_level = unit.find('.char-portrait-full-level').text()
unit_gear = romans.get(unit.find('.char-portrait-full-gear-level').text())
print(unit_name, unit_level, unit_gear)
return page
def get_squad_urls(user):
page = pq(url="https://swgoh.gg/u/{}/squads/".format(user))
return ['https://swgoh.gg{}'.format(x.attr('href')) for x in page('a[href*="squads/"].panel-profile.panel-a').items()]