-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
33 lines (28 loc) · 903 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from exa_py import Exa
import os
import csv
# Initialize Exa clientt
exa = Exa(os.getenv("EXA_API_KEY"))
# Perform search and get contents in a single call
results = exa.search_and_contents(
"Manufacturers specializing in high-precision machining for aerospace turbine components",
use_autoprompt=True,
num_results=1000,
type="neural",
category="company",
summary=True
)
# Write results to CSV
csv_file = "aero-turbine-manufacturers.csv"
with open(csv_file, mode='w', newline='', encoding='utf-8') as file:
writer = csv.writer(file)
# Write the header
writer.writerow(["URL", "Published Date", "Summary"])
# Write the data
for result in results.results:
writer.writerow([
result.url,
result.published_date,
result.summary if hasattr(result, 'summary') else ""
])
print(f"Results written to {csv_file}")