fork download
  1. import re
  2. import html
  3. import json
  4.  
  5. s= """j kj klajkldj lkdjslak jk
  6. <script type="application/ld+json">&#13;
  7. {&#13;
  8. "@context": "http://s...content-available-to-author-only...a.org",&#13;
  9. "BaseSalary": {&#13;
  10. "Currency": "USD",&#13;
  11. "Value": {&#13;
  12. "UnitText": "YEAR",&#13;
  13. "@type": "QuantitativeValue"&#13;
  14. },&#13;
  15. "@type": "MonetaryAmount"&#13;
  16. },&#13;
  17. "DatePosted": "2020-05-15T05:04:20.193",&#13;
  18. "EducationRequirements": "",&#13;
  19. "EmploymentType": [&#13;
  20. "FULL_TIME"&#13;
  21. ],&#13;
  22. "ExperienceRequirements": "",&#13;
  23. "Identifier": "927323",&#13;
  24. "HiringOrganization": {&#13;
  25. "Name": "Staples Stores",&#13;
  26. "@type": "Organization"&#13;
  27. },&#13;
  28. "JobLocation": {&#13;
  29. "Address": {&#13;
  30. "AddressLocality": "Elgin",&#13;
  31. "AddressRegion": "IL",&#13;
  32. "AddressCountry": "US",&#13;
  33. "PostalCode": "60123",&#13;
  34. "@type": "PostalAddress"&#13;
  35. },&#13;
  36. "Geo": {&#13;
  37. "Latitude": 42.03891,&#13;
  38. "Longitude": -88.31189,&#13;
  39. "@type": "GeoCoordinates"&#13;
  40. },&#13;
  41. "@type": "Place"&#13;
  42. },&#13;
  43. "Title": "Xerox Certified iGen Operator",&#13;
  44. "@type": "JobPosting"&#13;
  45. }&#13;
  46. </script>&#13;
  47. ds ad sad ksalkd l;ask;l"""
  48.  
  49. print(json.loads(html.unescape(re.search(r"""<script\s+type\s*=\s*(["']?)application/ld\+json\1\s*>((?:(?!</script>)[\s\S])+)</script>""", s).group(2))))
Success #stdin #stdout 0.02s 10208KB
stdin
Standard input is empty
stdout
{'@context': 'http://s...content-available-to-author-only...a.org', 'BaseSalary': {'Currency': 'USD', 'Value': {'UnitText': 'YEAR', '@type': 'QuantitativeValue'}, '@type': 'MonetaryAmount'}, 'DatePosted': '2020-05-15T05:04:20.193', 'EducationRequirements': '', 'EmploymentType': ['FULL_TIME'], 'ExperienceRequirements': '', 'Identifier': '927323', 'HiringOrganization': {'Name': 'Staples Stores', '@type': 'Organization'}, 'JobLocation': {'Address': {'AddressLocality': 'Elgin', 'AddressRegion': 'IL', 'AddressCountry': 'US', 'PostalCode': '60123', '@type': 'PostalAddress'}, 'Geo': {'Latitude': 42.03891, 'Longitude': -88.31189, '@type': 'GeoCoordinates'}, '@type': 'Place'}, 'Title': 'Xerox Certified iGen Operator', '@type': 'JobPosting'}