Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

reddit question 003

By: a guest on Oct 20th, 2012  |  syntax: Python  |  size: 0.78 KB  |  views: 41  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import time
  2. import datetime
  3. import urllib
  4. import re
  5. #from BeautifulSoup import BeautifulSoup
  6. #import smtp
  7.  
  8. def pollArduinoFileIndex(delayTime):
  9.     dataTimestamp = datetime.datetime.strftime(datetime.datetime.now(), "%Y%m%d_%H%M%S")
  10.         #dataTimestamp = str(dataTimestamp)
  11.     urllib.urlretrieve ("http://xxx.xxx.xx.xx:yyy/", "urlIndex.html")
  12.     dataFile = open('urlIndex.html', 'r')
  13.     data = dataFile.read()
  14.     fileIndex = re.findall('DATA.*?\.CSV', data)
  15.     #print fileIndex
  16.     for file in fileIndex:
  17.         #print file
  18.         url = ('http://xxx.xxx.xx.xx:xxx/%s' % file)
  19.         #print url
  20.         urllib.urlretrieve (url, '/Users/xxx/Documents/xxx/20121019/%s' % file)
  21.         print "."
  22.     print("url retrieve done")
  23.     time.sleep(delayTime)
  24.        
  25. pollArduinoFileIndex(1)