Hi!
I have a script that is scraping an internal webpage for contact information including email, phone, last name, and full name. So far it is in a list format {“email”, “phone”, “last”, “first”}.
My goal is to create a new FileMaker record for each new contact and populate fields for email, phone, last and first names. Since theres multiple contacts all in the one AS list I’m not quite sure how to do it.
I found some code that will create new records for everything in the list but I’m not sure how to indicate the parts I want as fields. Any help is much appreciated!
--try
tell application "Safari"
set pageHTML to source of document 1
end tell
set TID to AppleScript's text item delimiters -- save previous value
set theList to {}
------- Find Email Address ----------
considering case
set text item delimiters to "Email Address :
</TD>
</TR>
<TR>
<TD style=\"padding:3px\">
"
set emaila to text items 2 thru -1 of pageHTML
end considering
set text item delimiters to " "
------- Find Phone Number ----------
set text item delimiters to "Primary Phone :
</TD>
</TR>
<TR>
<TD style=\"padding:3px\">
"
set phonen to text items 2 thru -1 of pageHTML
set text item delimiters to " "
------- Find Last Name ----------
set text item delimiters to "Last Name :
</TD>
</TR>
<TR>
<TD style=\"padding:3px\">
"
set lname to text items 2 thru -1 of pageHTML
set text item delimiters to " "
------- Find First Name ----------
set text item delimiters to "First Name :
</TD>
</TR>
<TR>
<TD style=\"padding:3px\">
"
set fname to text items 2 thru -1 of pageHTML
set text item delimiters to " "
repeat with i from 1 to count of emaila
set end of theList to text item 1 of (item i of emaila)
set end of theList to text item 1 of (item i of phonen)
set end of theList to text item 1 of (item i of lname)
set end of theList to text item 1 of (item i of fname)
end repeat
set text item delimiters to TID
return theList
--end try
tell application "FileMaker Pro Advanced"
tell document "myDocument"
show layout "DataManipulationLayout"
tell table "data"
repeat with theList in theList
create a new record with data theList
end repeat
end tell
end tell
end tell