Python 3.7 - Help PLS -- AttributeError: 'str' object has no attribute 'append' [Closed]

Posts
32
Registration date
Friday November 14, 2014
Last seen
November 11, 2018
-
# import library
from requests import get
from bs4 import BeautifulSoup as bs
import pandas as pd
from time import time
from time import sleep
from random import randint
from IPython.display import clear_output
from warnings import warn

# declaration variables
SumNames = ["camarasama", "mefisto225", "Saber+Milena"]
TotalRank = []
Tier_Rank = []
TierInfoLP = []
wins = []
losses = []
winratio = []

# creation of the loops
start_time = time()
requests = 0

# requests for the page
for name in SumNames:
response = get('http://euw.op.gg/summoner/userName='+ name)

# break between requests
sleep(randint(1,2))

# information about the requests
requests += 1
elapsed_time = time() - start_time
print('Request: {}; Frequency: {} requests/s'.format(requests, requests/elapsed_time))
clear_output(wait = True)

# if response != 200
if response.status_code != 200:
warn('Request: {}; Status code: {}'.format(requests, response.status_code))
break

# extract the page
page_html = bs(response.text, 'html.parser')

# select the summoner container information
summoners_infos = page_html.find_all('div', class_="tabItem")
SumName = name

# Retreiving Summoner information
#create loop to retreive information
for summoner_info in summoners_infos:

#extract the League Point
TierInfoLPs = page_html.find('span', class_="LeaguePoints").text
TierInfoLPs.append(TierInfoLP)

# extract the Total Rank
TotalRanks = page_html.find('span', class_="ranking").text
TotalRanks.append(TotalRank)

# extract the Tier Rank
Tier_Ranks = int(page_html.find('span', class_="tierRank").text)
Tier_Ranks.append(Tier_Rank)

# extract the wins
win = page_html.find('span', class_="wins").text
wins.append(win)

# extract the losses
losse = page_html.find('span', class_="losses").text
losses.append(losse)

# extract the winratio
winratios = page_html.find('span', class_="winratio").text
winratios.append(winratio)
# print(winratio)
#display Data
player_data = pd.DataFrame({
'Nom Invocateur': [SumName],
'Rank Total': [TotalRank],
'Helo': [Tier_Rank],
'Nbre de Points': [TierInfoLP],
'Nbre Victoire': [wins],
'Nbre Defaite': [losses],
'Ratio Victoire': [winratio]
})
print(player_data)

i get the below error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-98-c194ce619f5f> in <module>()
30 #extract the League Point
31 TierInfoLPs = page_html.find('span', class_="LeaguePoints").text
---> 32 TierInfoLPs.append(TierInfoLP)
33
34 # extract the Total Rank

AttributeError: 'str' object has no attribute 'append'
------------------------------------------------------------------------------
also when i don't put append methode, the result in the dataframe at the colonne of TierInfoLP, it comes with spaces, how to remove the spaces?
See more