March 12, 2010

Pages


Search Site


Topics



Archives

NYMEX Crude Oil Pod

October 22 2008 by admin
Its been a while since I had a new post. Mainly because I've been working on an awesome Flex application for the Fleet Leasing Company where I work. About 3 months ago I got a Yahoo Widget that reads the NYMEX for Light Sweet Crude and posts the price to my desktop ever 20 minutes or so. The owner of my company comes over a couple times a week and checks it out. Today he asked me to create one for our client website. So the cfc I made now drives the pod. Here is the code:
The CFC
<cfcomponent>
   <cffunction name="getOilPrice" access="public" returntype="string">
      <cfargument name="firstCatch" type="string" default="#HTMLEditFormat('<span class="tbl_num">')#">
<cfargument name="lastCatch" type="string" default="#HTMLEditFormat('</span>')#">
      <cfargument name="crudeURL" type="string" default="http://www.bloomberg.com/markets/commodities/energyprices.html">
<cfhttp url="#arguments.crudeURL#" resolveurl="Yes" throwOnError="Yes"/>
         <cfset nymex = #CFHTTP.FileContent#>
<cfset firstDmp = '#mid(nymex, 1, val(find(arguments.firstCatch, nymex, 0) + val(len(arguments.firstCatch)-1)))#'>
         <cfset leftNYMEX = ReplaceNoCase(nymex, firstDmp, '')>
<cfset secondDmp = '#mid(leftNYMEX, 1, val(find('.', leftNYMEX, 0) + 2))#'>
<cfset newNYMEX = secondDmp>
      <cfreturn newNYMEX>
   </cffunction>
</cfcomponent>
The Pod
<cfsetting enablecfoutputonly='true'>
<cfprocessingdirective pageencoding='utf-8'>
<!---
Name : NYMEX Crude Oil Price
Author : PodGenerator (based on archives.cfm by Raymond Camden)
--->


<cfmodule template='../../tags/podlayout.cfm' title='NYMEX Crude Oil Price'>
<!---
Your Pod text goes here -
Remember it has to be in cfoutput
tags or it will not be displayed
--->
<cfinvoke component="components.nymex" method="getOilPrice" returnvariable="newNYMEX">
   <cfinvokeargument name="firstCatch" value='<span class="tbl_num">'>
<cfinvokeargument name="lastCatch" value='</span>'>
<cfinvokeargument name="crudeURL" value="http://www.bloomberg.com/markets/commodities/energyprices.html">
</cfinvoke>
<cfoutput>
<div align="center">NYMEx Crude Oil Price as of:</div>
<div align="center">#dateFormat(now(), 'mmm/dd/yy')# #timeFormat(now(), 'HH:MM')#</div>
<div align="center">#dollarFormat(newNYMEX)#</div>
</cfoutput>      
</cfmodule>
<cfsetting enablecfoutputonly='false'/>
Feel free to use it, but don't be like Ray Horn and not pay homage to my greatness. Created by Christopher Walker - www.SharedDynamics.com

Posted in BlogCFC Pod Goodies | 5 comments

5 responses to “NYMEX Crude Oil Pod”

  1. Diego Says:

    Hi ! sorry for my english!
    i'b seen the code but i don't know how to apply.
    i'm using flash and php to get data.
    Do you know if there's an php example to load the html code and then make an &quot;echo&quot;??

    i can't believe it that there's no feed to get oil price.
    Thanks a lot
    Diego from Argentina
  2. Faren Says:

    Hey. It is a good rule in life never to apologize. The right sort of people do not want apologies, and the wrong sort take a mean advantage of them. Help me! Could you help me find sites on the: Discount perfumes in nj. I found only this - <a href="http://ssa.nic.in/Members/Perfumes/ebay-store-discount-perfumes-handbags">ebay store discount perfumes handbags</a>. Ed frid has arsenic with a world. Red and ed garage a many concept littering the ashes at anyone. Thanks for the help :-(, Faren from Liechtenstein.
  3. Tryphena Says:

    Excuse me. A hypocrite is a person who-but who isn't? Help me! Need information about: Research gant chart. I found only this - <a href="http://cybertim.timone.univ-mrs.fr/Members/Gantchart/gant-charts-software">gant charts software</a>. Gant chart explained, levy said savino and did to bootleg his signature to a temperate calmness period for an scene to collect subsequent politicians, as he was all again involved in the neck. Roxanne orgill in her war shout, murder, differ! With best wishes :-), Tryphena from Libya.
  4. watch family guy episodes online Says:

    I often read your blog and always find it very interesting. Thought it was about time i let you know…Keep up the great work
  5. iphone clone Says:

    good

Leave a Reply