Aarrgghh!!

Wikipedia Scraper

Explanation

To power the Wikipedia Showdown, I had to write a Wikipedia scraper. I'm hope someone out there might use it to do something legitimate.

Sample Usage

Calling this code:

		


1: <cfinvoke component="pathtocfcs.wikipedia" method="weigh" returnvariable="results_1">
2: 	<cfinvokeargument name="search_term" value="diet coke" />
3: </cfinvoke>
4: 			
5: <cfdump var="#results_1#">


Will return:

CONTENTSWikipedia, the free encyclopedia   (Redirected from Diet coke) Jump to: navigation, search This article needs additional citations for verification. Please help improve this article by adding reliable references. Unsourced material may be challenged and removed. (January 2008) Diet Coke Type Diet Cola Manufacturer The Coca-Cola Company Country of origin United States Introduced 1982 Variants Diet Coke Caffeine-Free, Diet Coke with Lemon, Diet Coke with Lime, Diet Raspberry Coke, Diet Black Cherry Vanilla Coke, Diet Coke Sweetened with Splenda, Diet Coke Plus Related products Coca-Cola Coca-Cola C2 Coca-Cola Zero TaB Diet Coke (formally known as Diet Coca-Cola) is a sugar-free soft drink produced and distributed by The Coca-Cola Company. It was introduced in the United States on Independence Day in 1982 as the first new brand since 1886 to use the Coca-Cola trademark. The product quickly overtook Tab in sales. Diet Coke was sweetened with aspartame after the sweetener became available in the United States in 1983; however, to save money, this was originally in a blend with saccharin. After Diet Rite cola advertised its 100 percent use of aspartame, and the manufacturer of NutraSweet (then, G.D. Searle & Company) warned that the NutraSweet trademark would not be made available to a blend of sweeteners, Coca-Cola switched the formula to 100 percent NutraSweet, later switching back and doing without the NutraSweet trademark. Diet Coke from fountain dispensers still contains some saccharin (to extend shelf life).[1] Coca-Cola light logo. In other countries, in which cyclamates are not banned (as they were in the U.S. and the United Kingdom in 1970), Diet Coke or Coca-Cola Light may be sweetened with a blend containing cyclamates, aspartame, and acesulfame potassium. In 2005, under pressure from retailer Wal-Mart (which was impressed with the popularity of Splenda sweetener), the company released a new formulation called "Diet Coke sweetened with Splenda". Sucralose and acesulfame potassium replace aspartame in this version. Early sales were weaker than anticipated; however, Coca-Cola did little advertising for the brand, investing money and advertising in Coca-Cola Zero instead. Diet Coke does not use a modified form of the Coca-Cola recipe, but instead an entirely different formula. The controversial New Coke, introduced in 1985, used a version of the Diet Coke recipe that contained high fructose corn syrup and had a slightly different balance of ingredients. In 2004, Coca-Cola introduced Coca-Cola C2, which it claims tastes much closer to Coca-Cola but contains half the carbohydrates. In 2005, the company introduced Coca-Cola Zero, a sugar-free variation of regular Coca-Cola. When Tab was released in 1963, the Coca-Cola Company refused to release a diet soda with the Coca-Cola name, fearing that its flagship brand might suffer. Its rival Pepsi had no such qualms, and after the long-term success of its sugar-free Diet Pepsi (launched in 1964) became clear, Coca-Cola decided to launch a competing sugar-free brand under the Coca-Cola name, which could be marketed more extensively than the more anonymous Tab. Diet Coke and Diet Pepsi have capitalized on the markets of people who require low sugar regimens, such as diabetics, athletes, and people concerned with calorie intake. In the UK, a 330 ml can of Diet Coke contains around 1.3 calories (5 kilojoules) compared to 142 calories (595 kJ) for a regular can of Coca-Cola. Contents 1 Brand portfolio 2 Advertising slogans in the U.S. 3 Debate over health issues 4 Ingredients 5 Mentos eruption 6 References 7 External links // [edit] Brand portfolio Name Launched Discontinued Notes Picture Diet Coke 1982 The first version of Coca-Cola without sugar. Diet Coke Caffeine-Free 1983 A caffeine free version of Diet Coke and the first extension of the Diet Coke formula. Diet Cherry Coke/Diet Coke Cherry 1988 Available in USA and United Kingdom. Discontinued in Australia and Israel. Diet Coke with Lemon 2001 Still available in Austria, Belgium, Brazil, Canada, Chile, Bosnia and Herzegovina, Germany, Hong Kong, The Netherlands, South Africa, Spain and Israel. The version sold in Continental Europe uses the Coca-Cola Light brand and is generally thought to match much better with the lemon flavoring than the Diet Coke formula. Diet Vanilla Coke/Diet Coke Vanilla 2002 Still available in Hong Kong, New Zealand (only 300mL and 600mL), Australia, and Bosnia and Herzegovina. Diet Coke with Lime 2004 Available in the USA, Ireland, Finland, Sweden, Canada and Bosnia and Herzegovina. Diet Raspberry Coke June 1, 2005 2006 Available in New Zealand, and Bosnia and Herzegovina Diet Coke Sweetened with Splenda 2005 Available in the USA, and Bosnia and Herzegovina. Diet Coke Black Cherry Vanilla 2006 2007 available in Bosnia and Herzegovina. Coca-Cola Light Sango 2005 Only available in Belgium, France, Luxembourg, and Bosnia and Herzegovina Diet Coke with Citrus Zest 2007 Available in the Bosnia and Herzegovina, and United Kingdom. Diet Coke Plus/Coca Cola Light plus 2007 Available in many European countries and in the USA. In the United States and most English-speaking countries, the soft drink is called Diet Coke or Diet Coca-Cola. In most of continental Europe, the drink is marketed as Coca-Cola Light, but often referred to as Cola or Cola Light. Coca-Cola has tried to discourage the use of these generic terms,[citation needed] and commercials refer only to "Coke Light" or "Coca-Cola Light." In French-speaking Canada it is called Coca-Cola Diète. In Italy, the name Diet Coke was used between 1983 and 1991. In Mexico, Central, South America and most of the Caribbean it is called Coca-Cola Light. In Mexico, it was introduced as Diet Coke in 1984, but it was renamed Coca-Cola Light in 1991. In Brazil, it is called Coca-Cola Light - Baixas Calorias. In many English-influenced non-English markets e.g. Chile and Israel, it is called Diet Coca-Cola. In Japan, the soft drink was launched in 1984 as Coca-Cola Light, later in 1999, it was renamed Diet Coca-Cola, and since April 2007 it has been called No Calorie Coca-Cola. In India it is called Diet Coke. After much campaigning against Coca-Cola in India, Coca-Cola still sells well in Chennai and other cities. [edit] Advertising slogans in the U.S. The current Diet Coke logo was adopted in 2007 "The time is right" (1982) The band Devo served as spokespersons for just 1982 "Just for the taste of it!" (1983) "The one of a kind" (1984) "Just for the taste of it!" (1985) "Taste it all!" (1993) "This Is Refreshment" (1994) "Just for the taste of it!" (1995) "You are what you drink" (1997) "Get the taste of it" (2000) "Live Your Life" (2001) "Do what feels good" (2002) "It's a Diet Coke thing" (2004) "Life is how you take it" (2005) "Light it up!" (2006) "Yours" (2007) "Enjoyment" (2007) "What life should be like." (2008) [edit] Debate over health issues Wikinews has related news: Fizzy drinks out of New Zealand schools from 2009 The most commonly distributed version of Diet Coke (and majority of beverages using artificial sweeteners) relies on Aspartame, which has been blamed by some scientists and medical professionals for possibly causing serious illnesses (such as cancer, brain tumors, brain lesions, and lymphoma) when consumed in large quantities[2][3]. One of the chemicals produced by aspartame after ingestion is methanol.[4][5] It should be noted that Coca-Cola has now released Diet Coke sweetened with sucralose (also known as Splenda), although it is not as common. See also soft drink controversy. Also, the sodium benzoate was found to break down mitochondrial DNA in living yeast cells.[6] [edit] Ingredients The ingredients in Diet Coke are listed in order of greatest to least amount: Carbonated Water Caramel Color Aspartame Phosphoric Acid Potassium Benzoate (to protect taste) Natural Flavors Citric Acid Caffeine [edit] Mentos eruption A Diet Coke geyser during a Diet Coke and Mentos eruption Main article: Diet Coke and Mentos eruption It is possible to cause a sudden high-pressure release of carbon dioxide by inserting multiple Mentos into a container of Diet Coke. The MythBusters found that this is caused because of nucleation as well as certain catalysts in the Diet Coke and Mentos themselves. [edit] References ^ Ordoñez, Franco. "Suit Alleges Deceit in Fountain Diet Cola Drinks". Boston Globe, March 3, 2005. Accessed 26 August 2008. ^ Study Links Aspartame To Cancer, Lymphoma, Leukemia In Rats Fed Sweetener; Some Dispute Results - CBS News ^ http://www.ehponline.org/members/2005/8711/8711.pdf ^ Howstuffworks "Will aspartame make me go blind?" ^ http://www.factmonster.com/ce6/sci/A0804226.html ^ Caution: Some soft drinks may seriously harm your health from The Independent [edit] External links Official site v • d • e Varieties of Coca-Cola Coca-Cola · New Coke · Caffeine-Free Coca-Cola · Coca-Cola Cherry · Coca-Cola with Lime · Coca-Cola Vanilla · Coca-Cola Citra · Coca-Cola Black Cherry Vanilla · Coca-Cola Blāk · Coca-Cola with Lemon · Coca-Cola Raspberry · Diet Coke/Coke Light · Coca-Cola C2 · Coca-Cola Zero · Coca-Cola Cherry Zero · Coca-Cola Light Sango · Diet Coke Plus · Coca-Cola Orange Retrieved from "http://en.wikipedia.org/wiki/Diet_Coke"
LENGTH9582
SEARCHTERMdiet coke
URLhttp://en.wikipedia.org/wiki/Diet_Coke

Code

Source

		


1: <cfcomponent>
2: 	<!--- Stolen from cflib.org--->
3: 	<cffunction access="public" name="stripHTML" output="false" returntype="string" hint="Removes HTML from input string.">
4: 		<cfargument name="str" type="string" hint="String to clean." required="yes">
5: 		<cfreturn REReplaceNoCase(str,"<[^>]*>","","ALL")>
6: 	</cffunction>
7: 		
8: 	<cffunction access="public" name="weigh" output="true" returntype="struct">
9: 		<cfargument name="search_term" type="string" required="yes" hint="The search term. ">
10: 		
11: 		<cfset search_url="http://en.wikipedia.org/wiki/Special:Search">
12: 		<cfset return_struct.searchTerm=arguments.search_term>
13: 		
14: 		<cfhttp url="#search_url#" method="post" delimiter="," resolveurl="no">
15: 			<cfhttpparam type="formfield" name="search" value="#arguments.search_term#" />
16: 		</cfhttp>
17: 		
18: 		<cfif findNoCase("Search - Wikipedia, the free encyclopedia", cfhttp.FileContent)>
19: 			<cfset return_struct.contents="There are no records for that search term.">
20: 			<cfset return_struct.length=0>
21: 			<cfset return_struct.url="">
22: 			<cfreturn return_struct>
23: 		</cfif>
24: 		
25: 		<cfset contents=cfhttp.FileContent>
26: 		
27: 		<cfset contents_start=FindNoCase("bodyContent", contents)>
28: 		<cfset contents_end=FindNoCase("catlinks", contents)>
29: 		<cfset contents_len=(contents_end-contents_start)>
30: 		
31: 		<cfset contents=Mid(contents,contents_start, contents_len)>
32: 		<cfset contents=stripHTML(contents)>
33: 		<cfset contents_crap=14+9> 
34: 		
35: 		<cfset contents=Mid(contents, 14, Len(contents) -contents_crap)>
36: 		
37: 		
38: 		<cfset return_struct.contents=contents>
39: 		<cfset return_struct.length=Len(contents)>
40: 		
41: 		<cfset retrieved_location=FindNoCase("Retrieved from",contents)>
42: 		<cfset article_url=Mid(contents, retrieved_location, Len(contents) - retrieved_location)>
43: 		
44: 		<cfset article_url=replace(article_url,"Retrieved from", "", "ALL")>
45: 		<cfset article_url=replace(article_url,"""", "", "ALL")>
46: 		<cfset article_url=trim(article_url)>
47: 		<cfset return_struct.url=article_url>
48: 	
49: 		<cfreturn return_struct>
50: 	
51: 	</cffunction>
52: 
53: 
54: 
55: </cfcomponent>