An automated tool for commercial real estate (CRE) professionals to generate polished, image-rich property reports from CoStar listing data.
The tool automates the tedious process of extracting property data and images from CoStar and formatting them into a professional Word document. It uses AI-driven image classification to ensure floor plans and photos are placed in the correct sections of the report and automatically manages layout details like aspect ratio preservation and section duplication.
- Web Page: In your browser, navigate to the CoStar "For Lease" listing and save the page as Webpage, Complete into the
client/sub-folder (or any other folder of your choice, simply replace theclientreferences in the commands below with your custom folder path). This creates an.htmlfile and a corresponding_files/folder. - Brochure (Optional): Save the CoStar PDF tour report or property brochure into the
_files/folder of the property it pertains to.
When you run the generator:
- Parsing: The script parses the HTML to extract fields like address, rent, SF, and leasing contacts.
- AI Image Classification: It scans all images in the
_files/folder. Using the OpenAI CLIP model, it identifies which images are floor plans, interior views (offices/stores), or exterior views. - Note Injection: If a CoStar PDF is provided, the script extracts "Agent Notes" and matches them to the correct property via address reconciliation.
- Duplication: The tool takes a "Master Section" from your Word template and duplicates it for every property found in the
client/folder. - Surgical Injection: It replaces
{{VARIABLE}}text placeholders with property data and surgically injects images into pre-defined image placeholders. - Final Cleanup: It calculates aspect ratios to prevent image distortion and hides empty placeholder tags.
To generate a report from all HTML files in a folder:
python generate_report.py --input-folder "client/" --output "My_Report.docx"python generate_report.py `
--input-folder "client/" `
--template "property_report_template.docx" `
--output "Sunny_Report_May_2026.docx" `
--costar-pdf "client/TourReport.pdf" `
--client_name "John Doe" `
--client_co "Sunny Flowers Boutique" `
--agent "Jane Smith" `
--search-area "Midtown Manhattan" `
--budget "50-70" `
--size "1000-2000" `
--use-type "Retail"| Parameter | Description |
|---|---|
--input-folder |
Folder containing your saved CoStar HTML files. |
--template |
The .docx file to use as a starting point. |
--output |
The name/path of the final document to create. |
--costar-pdf |
(Optional) Path to a CoStar PDF to extract map and agent notes. |
--client_name |
The name of your client (fills {{CLIENT_NAME}}). |
--client_co |
The name of your client (fills {{CLIENT_COMPANY}}). |
--search-area |
Description of the search (fills {{SEARCH_AREA}}). |
--budget |
Rent range (fills {{BUDGET_MIN}} and {{BUDGET_MAX}}). |
--size |
SF range (fills {{SIZE_MIN}} and {{SIZE_MAX}}). |
The tool needs to know which part of your document to repeat for each property. Wrap your property detail page(s) in these two markers (each on its own line):
[[ PROPERTY_SECTION_START ]][[ PROPERTY_SECTION_END ]]Note: These markers are automatically made invisible in the final report.
To insert images, insert a "Placeholder" image in Word, right-click it, go to View Alt Text (or Format Picture > Alt Text), and set the Title to one of these exact names:
FloorPlan: The primary classified floor plan.Photo1,Photo2,Photo3,Photo4: The top 4 classified property photos.PropertyMapOverview: The overview map extracted from the CoStar PDF.
You can add any of these {{FIELD_NAME}} tags to your Word template. They will be automatically replaced with data from the CoStar listing.
{{PROPERTY_ADDRESS}}: Full address of the building.{{BUILDING_NAME}}: Name of the building (defaults to address).{{CITY_STATE_ZIP}}: City, State, and Zip code.{{SF_AVAILABLE}}: The specific SF available for lease.{{RENT_SF_YR}}: Asking rent per square foot per year.{{USE_TYPE}}: e.g., Office, Retail, Industrial.
{{BUILDING_TOTAL_SF}}: Total RBA of the building.{{YEAR_BUILT}}: Original construction year.{{FLOOR_LABEL}}: Which floor the space is on.{{SUITE_NAME}}: Suite number or name.
{{LEASE_TYPE}}: e.g., Direct.{{TERM}}: Length of lease.{{SERVICES}}: Utilities/Services included.{{BUILD_OUT}}: Condition of the space (e.g., Full Build-Out).{{SPACE_AMENITIES}}: Specific features listed in CoStar.
{{SPACE_NOTES}}: The public listing notes from CoStar.{{PERSONAL_NOTES}}: Private notes extracted from your CoStar PDF tour report.{{PHOTO_PAGE_1_NOTES}}: Optional notes for the photo pages.
{{LEASING_COMPANY}}: The brokerage firm.{{CONTACT_NAME}}: The primary listing agent.{{CONTACT_PHONE}}: The agent's phone number.