newsWebpage = "http://news.com.com"
#Location for output text file (change)
outputFileLocation = r"C:\\Documents and Settings\Owner\Desktop\JES\\TopNewsStories.txt"
#The actual grabbing of the webpage and storing its information in info
info = grabWebpage(newsWeb)
#The finding of information on the Yahoo webpage
breakdownTopStories(info, outputFileLocation)
#Finding our starting and stopping point.
#Starting point is stored in index becuase we will be updating
index = htmlInfo.find(startPhrase)
stoppingPoint = htmlInfo.find(stopPhrase,index)
#While we havent reached or passed by our stopping point, do all that is below.
while(index = stoppingPoint):
# Find a Row of Data
dataRow = htmlInfo.find("
",index)
#Find Date
start = htmlInfo.find('align="right',dataRow)
dateStart = htmlInfo.find(">",start)+1
dateEnd = htmlInfo.find("",dateStart)
#Write the date and add a tab to the end
outputFile.write(htmlInfo[dateStart:dateEnd]+"\t")
#Find Open
start = htmlInfo.find('align="right',dateEnd)
openStart = htmlInfo.find(">",start)+1
openEnd = htmlInfo.find("",openStart)
#Write the opening price and add a tab to the end
outputFile.write(htmlInfo[openStart:openEnd]+"\t")
#Find High
start = htmlInfo.find('align="right',openEnd)
highStart = htmlInfo.find(">",start)+1
highEnd = htmlInfo.find("",highStart)
#Write the daily high and add a tab to the end
outputFile.write(htmlInfo[highStart:highEnd]+"\t")
#Find Low
start = htmlInfo.find('align="right',highEnd)
lowStart = htmlInfo.find(">",start)+1
lowEnd = htmlInfo.find("",lowStart)
#Write the daily low and add a tab to the end
outputFile.write(htmlInfo[lowStart:lowEnd]+"\t")
#Find Close
start = htmlInfo.find('align="right',lowEnd)
closeStart = htmlInfo.find(">",start)+1
closeEnd = htmlInfo.find("",closeStart)
#Write the dailt close and add a tab to the end
outputFile.write(htmlInfo[closeStart:closeEnd]+"\t")
#Find REMOVEDlume
start = htmlInfo.find('align="right',closeEnd)
volumeStart = htmlInfo.find(">",start)+1
volumeEnd = htmlInfo.find("",volumeStart)
#Write the volume traded and add a tab to the end
outputFile.write(htmlInfo[volumeStart:volumeEnd]+"\t")
#Find Adj Close
start = htmlInfo.find('align="right',volumeEnd)
adjCloseStart = htmlInfo.find(">",start)+1
adjCloseEnd = htmlInfo.find("",adjCloseStart)
#Write the adjREMOVEDted closing price and add a newline to the end
outputFile.write(htmlInfo[adjCloseStart:adjCloseEnd]+"\n")
#Update
index = adjCloseEnd + 1
#Close the output File
outputFile.close()
Link to this Page
Brandy Depland last edited on 22 November 2004 at 1:52 pm by r57h94.res.gatech.edu