I'm trying to convert all the dates into timestamp from a url in json but I don't know what I'm doing wrong, it gives me the following error:
This is the code I'm using:
from datetime import datetime
from dateutil import relativedelta
from dateutil import parser
from datetime import datetime
from dateutil.parser import isoparse
import requests
separator = '\n'
url = requests.get("https://fortnite-api.com/v2/cosmetics/br/search/all?language=es&name=palito de pescado de gominola&searchLanguage=es")
historialSKIN= url.json()
for i in historialSKIN["data"]:
fecha = isoparse(*i['shopHistory'], sep=separator).timestamp()
print(fecha)
I want to get all dates in timestamp " 1652777302"
CodePudding user response:
As esqew said, isoparse
doesn't take a sep
argument. You should loop over the dates and parse them individually, like so:
for i in historialSKIN["data"]:
for datestr in i['shopHistory']:
fecha = isoparse(datestr).timestamp()
print(fecha)