Ast literal_eval() gives leading zeroes error when reading string containing dictionary

Question:

I am trying to use literal_eval() to read a string containing a dictionary that I am scraping from a site using requests and beautifulsoup. Need it to be in a dictionary so I can access the data more easily. Most cases have worked out fine, but I ran across an error I can’t seem to fix, nor find solutions for.

”’
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
”’

I’ve tried using json.dumps/.load and playing around with splitting up the string to make it easier to read. Anyways, this is the stringed dictionary that is giving me trouble:

{"@type":"JobPosting",
"title":"Coordinador de aduanas",
"hiringOrganization":{
"@type":"JobPosting",
"name":"Agencia Pública de Empleo", "sameAs":"https://agenciapublicadeempleo.sena.edu.co", "logo":"https://agenciapublicadeempleo.sena.edu.co/imgLayout/LOGO%20APE%201.png"},

"workHours":"Se informa el día de la entrevista",
"validThrough":"2022-08-25",

"jobLocation":{
"@type":"Place",
"address":{
"@type":"PostalAddress",
"addressCountry":"Colombia",
"addressLocality":"Medellín",
"addressRegion":"Antioquia"
}
},
"employmentType":"Indefinido",

"description": "funciones: Firmar documentos de importación y exportación según procesos y políticas de la organización – Asesorar a clientes sobre restricciones de importación y exportación, sistemas tarifarios, cartas de crédito, requisitos para el seguro y otros asuntos aduaneros. – Atender clientes según requerimientos y protocolos de servicio. – Desarrollar la operación de importación y exportación de mercancías según normativa de comercio exterior. – Controlar el proceso de importación y exportación de mercancías según normativa de comercio exterior. – Liquidar impuestos y derechos aduaneros de mercancías según normativa de comercio exterior.Técnico o tecnólogo en comercio exterior. alertar internamente sobre los beneficios que puede adquirir un cliente de acuerdo a lo establecido en la norma y gestionar oportunamente el manejo Financiero Régimen Aduanero. importación de vehiculos y autopartes buen manejo ofimatico Habilidades: " Verificar la documentación y comparar la misma con lo establecido normativamente para alertar sobre documentación faltante o errada. Diligenciar oportunamente y de forma correcta y precisa las declaraciones Gestionar documentación faltante con el servicio al cliente Alerta sobre omisiones o faltantes por parte del cliente que afecten el pago del impuesto" Competencias: "Analizar la documentación requerida para la nacionalización con el objetivo de proceder en la elaboración detallada de la declaración de importación y del valor, realizar el procedimiento de manera eficiente y eficaz, cumpliendo con los estándares establecidos por Aduanas ML frente a calidad, productividad y servicio",

"datePosted":"2022-07-11",
"baseSalary":{
"@type":"MonetaryAmount",
"currency":"COP",
"value":{
"unitText":"MONTH",
"@type":"QuantitativeValue",
"maxValue":"2000000",
"minValue":"1500001"
}
}
}

I thought this might be about the spanish characters in the description portion of the text, but I’ve had no trouble with that in other cases. Additionally, it might be the set of double quotes in the middle of the description, but I’m unsure of how to get rid of them if that’s the case.

Any help here would be greatly greatly appreciated!

Asked By: Jack Vaughan

||

Answers:

(please use markdown formatting)

In the data on the key description there are multiple uses of double quotes, which is likely causing the parsing errors.

{
    "description": "...manejo ofimatico Habilidades: " Verificar la doc..."
                                                     ^
                                                breaks parsing
}

Your solution would be to replace those with escaped quotes " or single quotes '

Answered By: haigou
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.