PDA

View Full Version : Simple applescript to check for text string on webpage




acribb
Nov 28, 2010, 08:16 AM
I'm looking for an applescript that searches a web page for a specific text string. So far, I have used curl to read in the webpage source, but now i'm not sure how to read that text into a variable to parse for the specific string.

Thanks for any help.

**edit** All I need to use is 'contains'



mwpeters8182
Nov 28, 2010, 10:32 AM
If you're using curl, you might as well just use grep to search for the string.

curl [url] | grep [string]

That should return all instances of the string in the text.

acribb
Nov 28, 2010, 10:39 AM
If you're using curl, you might as well just use grep to search for the string.

curl [url] | grep [string]

That should return all instances of the string in the text.

Thanks for the tip. I used curl to read the URL source into a variable. I then used an if check to check if it contains --string--. If it didn't, I emailed myself. (currently I am using it to check when the web page does not say 'out of stock')

jen234
Dec 1, 2010, 08:02 AM
You may also want to consider using Python, which these days seems to be the low-level language of choice or web based queries. Tons of libraries available.