Can't convert all dates to timestamp in python

Question:

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%20de%20pescado%20de%20gominola&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"

Asked By: juancarlos5487

||

Answers:

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)
Answered By: Dash
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.