Applescript to open webpages from list, search for "text"

posted this first in the shell area, realized it was wrong area for this, forgive me

hi guys, its me, doritos guy, I've laid off of the doritos for a while, twas given me stomach problems. you know when you eat 10 family size bags a day it might cause a problem, any-who

i appreciated the help from last time when i was trying to script something, now i just have to try to understand some hebrew lettering and sounds for phase 2 of that project.

i know it would be a combination of these two other discussions

Apple Automator to view a list of URLs fr… - Apple Community (i got this one to work for me)
Find text in webpage and email notificati… - Apple Community

basically something like this

Open webpages one at a time from list in txt file
when webpage is loaded, then search for "text"
if "text" is not found
then
close tab, open next URL in list
if "text" is found
then
copy URL to a text file or alert somehow.
once url is copied and saved
then
close tab, open next url in list
repeat

this is what i pieced together from these links

on run {input, parameters}  
     read (item 1 of input)  
     set ps to paragraphs of the result  
     set tot to count ps  
     tell application "Safari"  
          reopen  
          activate  
     end tell  
     repeat with i from 1 to tot  
          set p to item i of ps  
          if p is not "" then  
               try  
                    tell application "Safari"  
                         tell front window  
                              set r to make new tab with properties {URL:p}  
                              set current tab to r  
                              delay 1  
                              if i = tot then exit repeat  
                              repeat  
                                   delay 1  

if text in webpage contains "search text" then
                              copy URL to text file
                    end if
if text in webpage does not contain "search text" then
close tab





                                   get URL of r  
                              end repeat  
                         end tell  
                    end tell  
             end try  
          end if  
     end repeat  
end run