Sponsored Content
Top Forums Shell Programming and Scripting Applescript to open webpage from list, search for "text" Post 302939495 by ilovedoritos on Thursday 26th of March 2015 02:27:16 AM
Old 03-26-2015
Applescript to open webpage from list, search for "text"

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

https://discussions.apple.com/thread/6489693 (i got this one to work for me)
https://discussions.apple.com/thread/3122504

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


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  

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

---------- Post updated at 01:26 AM ---------- Previous update was at 01:12 AM ----------

just realized that i posted this in a shell scripting area, need to move

---------- Post updated at 01:27 AM ---------- Previous update was at 01:26 AM ----------

just realized that i placed this in a shell scripting area, need to move or delete

Last edited by ilovedoritos; 03-26-2015 at 03:16 AM.. Reason: messed up formatting
 

9 More Discussions You Might Find Interesting

1. SuSE

VMDB Failure" followed by "Unable to open snapshot file"

keep getting an error when I try to revert to a snapshot: "VMDB Failure" followed by "Unable to open snapshot file" Im using vmware server 1.0.4, host OS is windows xp and guest OS is SLES. Is there anything I can do to recover the snapshot or am I in trouble!?!?! (0 Replies)
Discussion started by: s_linux
0 Replies

2. IP Networking

Unknown open port: "6881/tcp open bittorrent-tracker" found with nmap

Hi. I ran nmap on my server, and I get the following: Starting Nmap 4.76 ( http://nmap.org ) at 2009-03-19 16:33 EDT Interesting ports on -------- (-----): Not shown: 997 closed ports PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 6881/tcp open bittorrent-tracker The... (0 Replies)
Discussion started by: Rledley
0 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

5. Shell Programming and Scripting

Read from "list1" and list matches in "list2"

I want to print any matching IP addresse in List1 with List 2; List 1 List of IP addresses; 161.85.58.210 250.57.15.129 217.23.162.249 74.76.129.101 30.221.177.237 3.147.200.59 170.58.142.64 127.65.109.33 150.167.242.146 223.3.20.186 25.181.180.99 2.55.199.32 (3 Replies)
Discussion started by: lewk
3 Replies

6. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

7. OS X (Apple)

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... (0 Replies)
Discussion started by: ilovedoritos
0 Replies

8. Open Source

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... (0 Replies)
Discussion started by: ilovedoritos
0 Replies

9. Shell Programming and Scripting

Expect: spawn id exp5 not open while executing "expect "$" { send "sudo su -\r" }"

Hi All, i am trying to ssh to a remote machine and execute certain command to remote machine through script. i am able to ssh but after its getting hung at the promt and after pressing ctrl +d i am gettin the out put as expect: spawn id exp5 not open while executing "expect "$" {... (3 Replies)
Discussion started by: Siddharth shivh
3 Replies
KNIFE-SEARCH(1) 						    Chef Manual 						   KNIFE-SEARCH(1)

NAME
knife-search - Find objects on a Chef Server by query SYNOPSIS
knife search INDEX QUERY (options) -a, --attribute ATTR Show only one attribute -i, --id-only Show only the ID of matching objects -q, --query QUERY The search query; useful to protect queries starting with - -R, --rows INT The number of rows to return -r, --run-list Show only the run list -o, --sort SORT The order to sort the results in -b, --start ROW The row to start returning results at -m, --medium Display medium sized output when searching nodes using the default summary format -l, --long Display long output when searching nodes using the default summary format DESCRIPTION
Search is a feature of the Chef Server that allows you to use a full-text search engine to query information about your infrastructure and applications. You can utilize this service via search calls in a recipe or the knife search command. The search syntax is based on Lucene. INDEXES
Search indexes are a feature of the Chef Server and the search sub-command allows querying any of the available indexes using SOLR query syntax. The following data types are indexed for search: o node o role o environment o clients o data bag Data bags are indexed by the data bag's name. For example, to search a data bag named "admins": knife search admins "field:search_pattern" QUERY SYNTAX
Queries have the form field:search_pattern where field is a key in the JSON description of the relevant objects (nodes, roles, environ- ments, or data bags). Both field and search_pattern are case-sensitive. search_pattern can be an exact, wildcard, range, or fuzzy match (see below). The field supports exact matching and limited wildcard matching. Searches will return the relevant objects (nodes, roles, environments, or data bags) where the search_pattern matches the object's value of field. FIELD NAMES Field names are the keys within the JSON description of the object being searched. Nested Keys can be searched by placing an underscore ("_") between key names. WILDCARD MATCHING FOR FIELD NAMES The field name also has limited support for wildcard matching. Both the "*" and "?" wildcards (see below) can be used within a field name; however, they cannot be the first character of the field name. EXACT MATCHES Without any search modifiers, a search returns those fields for which the search_pattern exactly matches the value of field in the JSON description of the object. WILDCARD MATCHES Search support both single- and multi-character wildcard searches within a search pattern. '?' matches exactly one character. '*' matches zero or more characters. RANGE MATCHES Range searches allows one to match values between two given values. To match values between X and Y, inclusively, use square brackets: knife search INDEX 'field:[X TO Y] To match values between X and Y, exclusively, use curly brackets: knife search INDEX 'field:{X TO Y}' Values are sorted in lexicographic order. FUZZY MATCHES Fuzzy searches allows one to match values based on the Levenshtein Distance algorithm. To perform a fuzzy match, append a tilda (~) to the search term: knife search INDEX 'field:term~' This search would return nodes whose field was 'perm' or 'germ'. BOOLEAN OPERATORS The boolean operators NOT, AND, and OR are supported. To find values of field that are not X: knife search INDEX 'field:(NOT X)' To find records where field1 is X and field2 is Y: knife search INDEX 'field1:X AND field2:Y' To find records where field is X or Y: knife search INDEX 'field:X OR field:Y' QUOTING AND SPECIAL CHARACTERS In order to avoid having special characters and escape sequences within your search term interpreted by either Ruby or the shell, enclose them in single quotes. Search terms that include spaces should be enclosed in double-quotes: knife search INDEX 'field:"term with spaces"' The following characters must be escaped: + - && || ! ( ) { } [ ] ^ " ~ * ? : EXAMPLES
Find the nodes with the fully-qualified domain name (FQDN) www.example.com: knife search node 'fqdn:www.example.com' Find the nodes running a version of Ubuntu: knife search node 'platform:ubuntu*' Find all nodes running CentOS in the production environment: knife search node 'chef_environment:production AND platform:centos' KNOWN BUGS
o Searches against the client index return no results in most cases. (CHEF-2477) o Searches using the fuzzy match operator (~) produce an error. (CHEF-2478) SEE ALSO
knife-ssh(1) http://wiki.opscode.com/display/chef/Attributes Lucene Query Parser Syntax http://lucene.apache.org/java/2_3_2/queryparsersyn- tax.html AUTHOR
Chef was written by Adam Jacob adam@opscode.com with many contributions from the community. DOCUMENTATION
This manual page was written by Joshua Timberman joshua@opscode.com. Permission is granted to copy, distribute and / or modify this docu- ment under the terms of the Apache 2.0 License. CHEF
Knife is distributed with Chef. http://wiki.opscode.com/display/chef/Home Chef 10.12.0 June 2012 KNIFE-SEARCH(1)
All times are GMT -4. The time now is 03:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy