from bs4 import BeautifulSoup
import requests

def statsRoyale(tag):
	link = 'http://statsroyale.com/profile/' + tag
	response = (requests.get(link)).text
	soup = BeautifulSoup(response, 'html.parser')
	stats = {}

	content = soup.find_all('div', {'class':'content'})
	stats['clan'] = content[0].get_text()
	if stats['clan'] == 'No Clan':
		stats['clan'] = None
	stats['highest_trophies'] = content[1].get_text()
	stats['last_known_trophies'] = content[2].get_text()
	stats['challenge_cards_won'] = content[3].get_text()
	stats['tournament_cards_won'] = content[4].get_text()
	stats['total_donations'] = content[5].get_text()
	stats['best_session_rank'] = content[6].get_text()
	stats['previous_session_rank'] = content[7].get_text()
	stats['legendary_trophies'] = content[8].get_text()
	stats['wins'] = content[9].get_text()
	stats['losses'] = content[10].get_text()
	stats['3_crown_wins'] = content[11].get_text()
	return stats

stats = statsRoyale(tag='9890JJJV')
print stats

from bs4 import BeautifulSoup
import requests

def statsRoyale(tag):
	if not tag.find('/') == -1:
		tag = tag[::-1]
		pos = tag.find('/')
		tag = tag[:pos]
		tag = tag[::-1]

	link = 'http://statsroyale.com/profile/' + tag
	response = (requests.get(link)).text
	soup = BeautifulSoup(response, 'html.parser')

	description = soup.find_all('div', {'class':'description'})
	content = soup.find_all('div', {'class':'content'})

	stats = {}

	for i in range(len(description)):
		description_text = ((description[i].get_text()).replace(' ', '_')).lower()
		content_text = content[i].get_text()
		stats[description_text] = content_text

	if stats['clan'] == 'No Clan':
		stats['clan'] = None

	return stats

stats = statsRoyale(tag='9890JJJV')
print stats

Use tags or direct url
Use tags or direct url