Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

kunal

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Getting and Parsing 10x10

Here's my source code in ColdFusion for parsing 10x10. I can't imagine it being different in other languages.

----

   1  
   2  <!--- build the wordsURL before getting the data --->
   3  <cfset year = DateFormat(Now(),"YYYY")>
   4  <cfset month = DateFormat(Now(),"MM")>
   5  <cfset day = DateFormat(Now(),"DD")>
   6  <cfset hour = TimeFormat(Now(),"HH")>
   7  <cfset wordsURL = "http://tenbyten.org/Data/#year#/#month#/#day#/#hour#/words.txt">
   8  
   9  <!--- connect to the url --->
  10  <cfhttp method="get" url="#wordsURL#" timeout="60"></cfhttp>
  11  
  12  <cfset wordlist = cfhttp.FileContent>
  13  
  14  <!--- write the data into a text file --->
  15  <cffile action="write" file="#ExpandPath('words.txt')#" output="#ToString(wordlist)#">


----

Reading the content is as simple as opening the file and traversing through it like so. I also added in a link to Google news. I've found it helpful to click on news bits in the past.

----

   1  
   2  <cfhttp method="get" url="http://path/to/words.txt" timeout="60"></cfhttp>
   3  
   4  <cfset wordlist = cfhttp.FileContent>
   5  
   6  <ul><li>
   7  <cfloop list="#wordlist#" delimiters="#chr(13)##chr(10)#" index="word">
   8    <cfoutput>
   9      <a href="http://news.google.com/news?q=#word#" target="_blank">#word#</a>
  10    </cfoutput>
  11  </cfloop>
  12  </li></ul>
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS