Zahlenformat ändern
Verfasst: Samstag 15. Januar 2022, 15:23
Hallo,
ich hab das Problem das mein "Web Scrapper" mir die Zahl in Google Sheet so ausgibt '12500. Durch das ' hab ich das Problem, dass die bedingte Formatierung bei jedem automatisierten Scrap nicht mehr funktioniert und ich erst manuel das Zahlenformat wieder ändern muss.
Gibt es in diesem Code die Möglichkeit das ' zu entfernen?
Ich bedanke mich schonmal ganz herzlich.
Ursprünglich wurde die Zahl mit '12,500 ausgegeben. Das , konnte bereits entfernt werden, aber mit dem ' bin ich überfragt. Vielen Dank für die Hilfe
ich hab das Problem das mein "Web Scrapper" mir die Zahl in Google Sheet so ausgibt '12500. Durch das ' hab ich das Problem, dass die bedingte Formatierung bei jedem automatisierten Scrap nicht mehr funktioniert und ich erst manuel das Zahlenformat wieder ändern muss.
Gibt es in diesem Code die Möglichkeit das ' zu entfernen?
Ich bedanke mich schonmal ganz herzlich.
Code: Alles auswählen
# Call the Sheets API
sheet = service.spreadsheets()
result = sheet.values().get(spreadsheetId=SAMPLE_SPREADSHEET_ID,
range=SAMPLE_RANGE_NAME).execute()
values = result.get('values', [])
print('values: ', values)
user_agent = {'User-agent': 'Mozilla/5.0'}
prices=[]
proxy_host = "proxy.zyte.com"
proxy_port = "8011"
proxy_auth = "db4255942ad341c78efcfef838239084:" # Make sure to include ':' at the end
proxies = {"https": "http://{}@{}:{}/".format(proxy_auth, proxy_host, proxy_port),
"http": "http://{}@{}:{}/".format(proxy_auth, proxy_host, proxy_port)}
r=requests.Session()
r.proxies = proxies
for i in values:
if i != []:
page=None
try:
page = r.get('https://www.futbin.com/22/playerPrices?player=' + i[0], verify='zyte-smartproxy-ca.crt')
print('page response: ', page.reason)
data=json.loads(page.content)
print(data)
psLcPrice = data[i[0]]['prices']['ps']['LCPrice']
xboxLcPrice = data[i[0]]['prices']['xbox']['LCPrice']
psMinPrice = data[i[0]]['prices']['ps']['MinPrice']
psMaxPrice = data[i[0]]['prices']['ps']['MaxPrice']
xboxMinPrice = data[i[0]]['prices']['xbox']['MinPrice']
xboxMaxPrice = data[i[0]]['prices']['xbox']['MaxPrice']
prices.append([psLcPrice.replace(',', ''), xboxLcPrice.replace(',', ''), psMinPrice.replace(',', ''), psMaxPrice.replace(',', ''), xboxMinPrice.replace(',', ''), xboxMaxPrice.replace(',', '')])
except:
print('page error: ')
prices.append('None')
else:
prices.append([])
print('Successfully got all Prices!')
modified = sheet.values().update(spreadsheetId=SAMPLE_SPREADSHEET_ID, valueInputOption="RAW" ,range="Python!E3", body={'values':prices}).execute()
getPlayerPrices()