+
    Ȱi                        R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ]! R4      t]R,          R,          t	Rt
]R,          t. ROtR	 tR
 tR tR tRR lt]R8X  dg   ]! ]	P)                  R4      4      t]'       d>   ]R,          t]! R]P0                   24       ]! ]4      t]'       d   ]! R] 24       R# R# ]! R4       R# R# )zi
PHT Enrichment Pipeline
Finds contacts at target companies and verifies emails

Created: March 11, 2026
N)Path)datetimez*/Users/max/.openclaw/workspace/postharvest
automationdata(fda8536970076bc3228c5b5fa6e19fdc407c43c9z.apollo-keyc                  a	 RpRV R\         R^
/p \        P                  ! W^
R7      pVP                  4        VP	                  4       pVP                  R4      '       Ed5   VR,          P                  R. 4      p. pV EF  pVP                  RR	4      P                  4       o	\        ;QJ d#    V	3R
 l\         4       F  '       g   K   RM	  RM! V	3R
 l\         4       4      '       g   Kn  VP                  RVP                  RR	4       RVP                  RR	4       2P                  4       RVP                  RR	4      RVP                  RR	4      RVP                  R/ 4      P                  R4      R8H  RVP                  R^ 4      RR/4       EK  	  V# . #   \         d   p\        RT  RT 24       . u Rp?# Rp?ii ; i)z1
Search for contacts at a domain using Hunter.io
z&https://api.hunter.io/v2/domain-searchdomainapi_keylimitparamstimeoutr   emailsposition c              3   ,   <"   T F	  qS9   x  K  	  R # 5iN ).0roler   s   & E/Users/max/.openclaw/workspace/postharvest/automation/2_enrichment.py	<genexpr>)search_contacts_hunter.<locals>.<genexpr>9   s     ALDx'Ls   TFname
first_name 	last_nametitleemailvalueverifiedverificationresultdeliverable
confidencesourcehunteru      ⚠ Hunter error for : N)
HUNTER_KEYrequestsgetraise_for_statusjsonloweranyTARGET_ROLESappendstrip	Exceptionprint)
r   urlr   responser   r   contactsr   er   s
   &        @r   search_contacts_hunterr8   "   s    3C&:F<<B?!!#}}88F&\%%h3F H 99Z4::<3ALA333ALAAAOO599\2#>"?q;XZA[@\ ] c c e:r!:7B!7"EIInb$A$E$Eh$OS`$`$eiia&@ (%    O	 (1#67	s8   AF !A$F F ,B(F F F?"F:4F?:F?c                   RpRV R\         /p \        P                  ! W^
R7      pVP                  4        VP	                  4       pVP                  R4      '       d=   VR,          P                  R4      pVR,          P                  R^ 4      pRVR	8H  RVRV/# RR
R^ RR/#   \
         d$   p\        RT  RT 24       RR
R^ RR/u Rp?# Rp?ii ; i)z)
Verify an email address using Hunter.io
z'https://api.hunter.io/v2/email-verifierr   r	   r   r   r"   scorevalidr#   Funknownu      ⚠ Verification error for r'   errorN)r(   r)   r*   r+   r,   r2   r3   )r   r4   r   r5   r   r"   r:   r7   s   &       r   verify_email_hunterr>   K   s     4C:F
?<<B?!!#}}88F&\%%h/FL$$Wa0E =0&  Hi@@ ?.ugRs;<Hg>>?s$   B
B! B! !C,C
C
Cc                j    V P                  4       p\        \        4       F  w  r#W19   g   K  Vu # 	  R# )zD
Rank contact priority based on title
Lower score = higher priority
i  )r-   	enumerater/   )r   title_lowerir   s   &   r   rank_contact_by_titlerC   j   s0    
 ++-K\*H +     c                   \        RV  24       \        RV 24       \        V4      pV'       g   \        R4       . # \        R\        V4       R24       VP                  R R7       VR,          p. pV EF!  pVR	,          '       d>   VP	                  V4       \        R
VR,           RVR,           RVR,           R24       KP  \        VR,          4      p\        P                  ! R4       VR,          '       dg   VR,          ^F8  dY   RVR	&   VR,          VR&   VP	                  V4       \        R
VR,           RVR,           RVR,           RVR,           R2	4       K  \        RVR,           RVR,           RVR,           RVR,           R2	4       EK$  	  V'       g   \        RV  24       V# \        R\        V4       R24       V# )zU
Find and verify contacts for a company

Returns top 3 contacts with verified emails
u   
📧 Enriching: z   Domain: u      ⚠ No contacts foundz	   Found z potential contactsc                 :    \        V R ,          4      V R,          ) 3# )r   r$   )rC   )xs   &r   <lambda> enrich_company.<locals>.<lambda>   s    !6qz!BQ|_DT UrD   )key:N   Nr    u      ✓ r   z (r   z) - r   z [verified]g      ?r;   r:   Tverification_scorez [verified: z%]u      ✗ z
 [failed: r"   ]u       ⚠ No verified contacts for u      ✅ z verified contacts)r3   r8   lensortr0   r>   timesleep)company_namer   r6   top_contactsverified_contactscontactr!   s   &&     r   enrich_companyrV   w   s    
|n
-.	Kx
 ! &f-H(*		Ic(m_$7
89 MMUMV B<L :$$W-GGFO,Bww/?.@WWEUDVVabc /ww/?@LJJsOG$$g)>")D&*
#0<W0E,-!((10773C2DDQXIYHZZfgst{g|f}}  A  B0773C2DDQXIYHZZdeqrze{d||}~!  $ 0?@  	-.//ABCrD   c           	        \        R4       \        RV  24       . p\        V RRR7      ;_uu_ 4       p\        P                  ! V4      p\	        V4      pRRR4       \        R\        V4       24       . p\        V^4       F  w  rg\        RV R	\        V4       R
24       \        VR,          VR,          4      pV Fk  p	VR,          V	R&   VR,          V	R&   VP                  RR4      V	R&   VP                  RR4      V	R&   \        P                  ! 4       P                  4       V	R&   Km  	  VP                  V4       \        P                  ! ^4       K  	  V'       g6   \        P                  ! 4       P                  R4      p
\         RV
 R2,          pV'       d   \        VRRRR7      ;_uu_ 4       p. ROp\        P"                  ! W;R7      pVP%                  4        VP'                  V4       RRR4       \        R4       \        R\        V4       24       \        R\        \)        R V 4       4      4       24       \        RV 24       \+        V4      # \        R4       R#   + '       g   i     EL; i  + '       g   i     L; i)z
Enrich all companies from discovery file

Args:
    discovery_file: Path to discovered companies CSV
    output_file: Path to save enriched contacts (optional)
u   
🔧 Starting enrichmentz
   Input: rzutf-8)encodingNz   Companies to enrich: z
[/rM   rR   r   countryr   
fruit_typeenriched_datez%Y%m%d_%H%M%Senriched_contacts_z.csvw)newlinerY   )
fieldnamesu   
✅ Enrichment complete!z   Total contacts: z   Companies with contacts: c              3   2   "   T F  qR ,          x  K  	  R# 5i)rR   Nr   )r   cs   & r   r   !run_enrichment.<locals>.<genexpr>   s     4]P\1~5F5FP\s   z
   Saved: u   
⚠ No contacts enriched)rR   r   r[   r\   r   r   r   r    r$   rL   r%   r]   )r3   opencsv
DictReaderlistrN   r@   rV   r*   r   now	isoformatextendrP   rQ   strftimeDATA_DIR
DictWriterwriteheader	writerowssetstr)discovery_fileoutput_file	companiesfreaderall_contactsrB   companyr6   rU   	timestampra   writers   &&           r   run_enrichmentr|      s@    
&(	J~&
'( I	ncG	4	4"L	 
5 
$S^$4
56 L	1-
A3aI'q)*!N#H
  G&-n&=GN# ' 1GH!(Y!;GI$+KKb$AGL!'/||~'?'?'AGO$   	H% 	

1' ., LLN++O<	#5i[!EE+sBAAQJJ ^^A=F \* B 	*,#C$5#678,S4]P\4]1]-^,_`a
;-();*+e 
5	4	4F BAs   "I'3=I;'I8	;J	__main__zdiscovered_*.csvzUsing latest discovery: u   
📁 Output: z3No discovery files found. Run 1_discovery.py first.)zquality managerzoperations managerzproduction managerztechnical managerzfacility managerzgeneral managerr   )__doc__rf   r,   r)   rP   pathlibr   r   	WORKSPACErm   r(   APOLLO_KEY_FILEr/   r8   r>   rC   rV   r|   __name__sortedglobdiscovery_fileslatestr3   r   r"   r   rD   r   <module>r      s          =>	|#f, 8
m+'R?>1f?B zX]]+=>?O $(67'OF8,-  	CD rD   