cPAMIE/Python String and Date Comparisons
RB
roger.baas at gmail.com
Tue Nov 8 19:59:29 EST 2005
Here's an example:
import cPAMIE
import time
from time import sleep
search_txt = 'MSNBC Pairs Chung, Povich'
date_txt = '8 November 2005'
date_tuple = time.strptime(date_txt,'%d %B %Y')
today_tuple = time.localtime()
if date_tuple[:3] == today_tuple[:3]:
print date_txt + ' is today\'s date.'
else:
print date_txt + ' is not today\'s date.'
ie=cPAMIE.PAMIE('http://www.prophet.net/quotes/stocknews.jsp?symbol=MSFT')
sleep(1) # let the browser start loading...
while ie.getIE().Busy: # wait for the page to fully load
sleep(1)
sleep(1) # extra pauses tend to help.
# Get ASCII string of page data without HTML tags.
page_txt =
str((ie.getIE().Document.body.innerText).encode('ascii','ignore'))
if search_txt in page_txt:
print '\"' + search_txt + '\"' + ' found on page.'
else:
print '\"' + search_txt + '\"' + ' not found on page.'
ie.Quit()
-RB
More information about the Python-list
mailing list