• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Best way to poll a URL for an alt code.

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Cerberus2k7

Drifto Mexicano
Joined
Feb 15, 2004
Location
Morris, IL
Ok guys, I'm noob status 101 x1000 with anything programming. I have a basic grasp on some of the logic behind it but syntax/actual languages I'm completely blank about. I want to write a simple script that polls a specific product URL for a "sold out" alt code. Long story short the GF has been wanting to buy some nail polish that's damn near impossible to find. So I want to write something to send me an email once it no longer sees the "sold out" alt for the image on the product page. I'm wondering if a bash script would be the easiest way to get this done, or something like python? Or something else entirely. :help:
 
Python or bash would both be a decent way to do it. Sending the email's a bit trickier. Windows or linux?
 
Python or bash would both be a decent way to do it. Sending the email's a bit trickier. Windows or linux?

Either really. My HTPC runs 7 and my laptop runs fedora. Probably have it run on my laptop and poll every 60 minutes or something to that extent.
 
Good - sending email is probably easier on linux. I've got two example programs for you - one checks a page for something to be in stock (I wrote it in python) and another pings my SSH server and sends me an email if it's down. Seems like you should be able to cobble something together out of relevant bits of each...

Email:
Code:
if ! echo $PROXY_STATUS | grep -q open; then
        echo "Subject:Proxy is down: $PROXY_STATUS"| /usr/sbin/sendmail -f Monitor [email protected]

Website:
Code:
import sys, re, httplib2, urllib

resp, content = httplib2.Http().request(url, 'GET', headers=None, body=None)
products = re.findall('<h2\sclass="product-name">.+</h2>', content)
You'll want a different regex, of course. Then just set up the script to be called from your cron tab.
 
Back