| 1 | import re |
| 2 | import json |
| 3 | |
| 4 | text = """ |
| 5 | No JSON content found. |
| 6 | I have found a lead sheet from the file "BORAN ZHAO- CORE AUSTIN TX.pdf" that contains information about a potential client. Here is the extracted lead information in JSON format: |
| 7 | |
| 8 | ```json |
| 9 | [ |
| 10 | { |
| 11 | "Agent's Name": "ANDREA", |
| 12 | "ROOFING COMPANY": "CORE FOUR - AUSTIN", |
| 13 | "Name(s)": "BORAN ZHAO & TANIA BETANCOURT", |
| 14 | "Appointment Date": "4/18/24", |
| 15 | "Time": "2PM", |
| 16 | "Phone": "979-218-4997", |
| 17 | "Email": "TANIA@TXSTATE.EDU", |
| 18 | "Address": "524 CARISMATIC LN", |
| 19 | "City": "AUSTIN", |
| 20 | "State": "TX", |
| 21 | "ZIP CODE": "78748", |
| 22 | "Insurance Provider": "METROPOLITAN/FARMERS", |
| 23 | "Age of Roof": "3", |
| 24 | "Any Animal in Yard?": "YES", |
| 25 | "When was the last time you had a Roof inspection?": "", |
| 26 | "Additional Address": "ALT # 512-291-2707" |
| 27 | } |
| 28 | ] |
| 29 | ``` |
| 30 | |
| 31 | This JSON list captures the lead details from the provided document. |
| 32 | """ |
| 33 | |
| 34 | regex = re.compile(r"```json(.*)```", re.DOTALL) |
| 35 | match = regex.search(text) |
| 36 | if match: |
| 37 | json_content = match.group(1) |
| 38 | parsed_json = json.loads(json_content) |
| 39 | print(json.dumps(parsed_json, indent=2)) |
| 40 | else: |
| 41 | print("No JSON content found.") |