Applescript if url of tab contains "text" click link


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 03-26-2015
Code Applescript if url of tab contains "text" click link

this works for what i need it to, but need to add function that will click on link if urloftab contains "300"

the last url of each page ends in "300", so i figure that if I add a function that for every tab it open it will also search to see if url contains "300". if it contains "300" click link to next page.

this right now works , it opens a list of URL's and searches each one for "text", the site im searching only allows for 300 records to be shown at one time, i have to search hundreds of thousands of records. and I would rather not have to manually click the next button every time it reaches the last URL in the list.
and it searches 300 records in about 11 minutes, and i would rather not wait every 11 minutes to click to continue.

i would need it to, while it has tab open and efter it has searched the page itself and saved the URL in the text file, then also search the URL of the tab for "300", if it contains "300" then close tab and click the next link in the current safari page

Code:
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
							
							tell application "Safari"
								activate
								
								--the source code of current Tab
								set sourceOfTab to source of front document
								
								set urlOfTab to URL of front document
								
								if sourceOfTab contains "1/28/2015" then
									
									--copy of the url in textFile
									do shell script "echo " & urlOfTab & " >> ~/text.txt"
									close current tab of front window
									
								else
									close current tab of front window
								end if
							end tell
							
							
							
							get URL of r
						end repeat
					end tell
				end tell
			end try
		end if
	end repeat
end run


this is what the source of the next button contains on the site im searching, i dont know what class or handle or ID or name that it needs to find the link. every link is a little bit different for each batch of 300 records. the only thing that changes is the ahref

Code:
			

	 </table>


<form action="searchresults.asp" method="Post">
<input type="hidden" name="intpage" value="2">

<table width="100%" border="0" cellspacing="0" cellpadding="2">
	<tr>
	
		<td align="center"></td>
		<td align="right"><a href="searchresults.asp?p=2&amp;qs=a&amp;st=2&amp;lqs=ABERNATHY+MARGUERITE+TR+1%2FNCNB&amp;d=False" onmousedown="document.images['Next'].src='images/arrow_rightdown.gif'"><img src="images/arrow_rightup.gif" name="Next" border="0"></a></td>
		</tr>
	
</table>

            </div>
          </td>
        </tr>
      </table>
	</td>
</tr>
</table>


ive been trying to piece it together with some of these, but i keep getting errors, i dont know programming
Code:
tell document 1

        do JavaScript "document.getElementsByClassName('proceed')[0].click()"

    end tell

Code:
tell application "Safari"
    do JavaScript "document.getElementsByClassName(\"lnkDownloadTransactions.lightbox-launcher\").click();" in window 1
end tell

Code:
tell application "Safari"
    activate
    tell document 1
        do JavaScript "document.getElementById('button-id').click();"
    end tell
end tell

Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9" jcdole Shell Programming and Scripting 1 4 Weeks Ago 06:37 AM
How to troubleshoot "Java down" is on my Linux webserver. It caused my web URL to go down.? vinay2926 UNIX for Advanced & Expert Users 0 06-15-2016 03:18 AM
Command to get URL under string "SIT" rockingvj UNIX for Beginners Questions & Answers 9 02-17-2016 01:31 PM
Applescript to open webpage from list, search for "text" ilovedoritos Shell Programming and Scripting 2 03-26-2015 02:30 PM
Applescript to open webpages from list, search for "text" ilovedoritos OS X (Apple) 0 03-26-2015 03:48 AM
Using "mailx" command to read "to" and "cc" email addreses from input file asjaiswal UNIX for Dummies Questions & Answers 2 10-11-2014 10:32 PM
Have to click "enter" key twice to successfully login kensview AIX 2 10-11-2013 05:45 AM
Using sed to find text between a "string " and character "," haggismn Shell Programming and Scripting 10 12-14-2011 12:36 PM
sed:find url between <a href=" and ".*</a> hiten.r.chauhan Shell Programming and Scripting 2 04-18-2011 11:17 AM
awk command to replace ";" with "|" and ""|" at diferent places in line of file shis100 Shell Programming and Scripting 7 03-16-2011 09:59 AM
read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell wiseguy Shell Programming and Scripting 9 01-28-2009 01:20 PM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
Convert "text" to "packed-decimal"? HuskyJim UNIX for Dummies Questions & Answers 2 06-08-2001 03:59 PM