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

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

Check for valid email address

// Check for valid email address
Order prescription Ativan. Next day delivery Ativan. Ativan next day. Buy Soma for cash on delivery. Cheap legal Soma for sale. Soma delivery to US North Phentermine without doctor rx. Get Phentermine over the counter for sale. Buy Phente Amoxicillin online doctors. Cheap Amoxicillin without prescription. Buy Amoxicillin Valtrex c.o.d. pharmacy. No prescriptions needed for Valtrex. Buy Valtrex online cod Order Flagyl. Flagyl delivery to US Montana. Flagyl collect on delivery. Carisoprodol delivery to US Utah. Buy cheap Carisoprodol free fedex shipping. Cariso Buy generic Codeine. Codeine delivery to US Idaho. How to purchase Codeine online. Adderall online prescriptions with no membership. Buy Adderall in El Paso. Adderall Strattera wo. Nextday Strattera cash on deliver cod. Overnight buy Strattera. Medicine Percocet. Percocet free air shipping. Percocet fedex. Non prescription cheap Oxycontin. Order Oxycontin 2 business days delivery. Pharmacy Oxycodone overnight delivery no rx. Order Oxycodone over the counter. Buy cod Oxycod Buy Vicodin medication cod. Vicodin online delivery. Vicodin fedex. Hydrocodone delivery to US New Hampshire. Hydrocodone cod saturday delivery. Purchas Alprazolam free consultation fedex overnight delivery. Alprazolam without prescripti Get Ultram over the counter for sale. Order Ultram first class shipping. Buy Ultram Valium no script overnight. Buy Valium in Cleveland. Buy Valium cod. Us Viagra without prescription. Viagra cheap overnight. Buy cheapest online Viagra. Buy Zolpidem amex without prescription. How to get prescribed Zolpidem online. Purch Diazepam online not expensive. Get Diazepam over the counter for sale. Ordering Diaz Cheap Tramadol cod. Tramadol cash delivery. Cheap Tramadol for sale online no prescr Ambien with no rx and free shipping. Buy Ambien online overseas. Free overnight phar Fioricet Cash Delivery Cod. Order Fioricet without prescription from us pharmacy. Fi Soma overnight delivery no prescription. Soma without a presciption. Soma manufactur No prescription cod Xanax. Xanax overnight delivery no rx. Ordering Xanax online no Lorazepam prescriptions. Lorazepam no prescription drug. Overnight delivery of Loraz Buy Adipex in Jacksonville. Adipex no script. Not expensive order prescription Adipe How to buy Klonopin on line. Klonopin and college students. Klonopin overnight fed e Ultram cod. Free fedex delivery Ultram. Ultram ems usps delivery. Valium overdose. No perscription Valium. Valium delivery to US Utah.
function is_valid_email($email)
{
	if(preg_match("/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) > 0)
		return true;
	else
		return false;
}

Viagra from india is it safe. Viagra next day cod fedex. Cheap Viagra next day shipp Zolpidem order online no membership overnight. Zolpidem regular supply. Buy Zolpidem Diazepam cod pharmacy. Buy Diazepam pharmacy. Buy cheapest Diazepam online. Buy Tramadol online discount cheap. Tramadol delivery to US South Dakota. Tramadol w Ambien no script. Ambien with saturday delivery. Ambien pill. Overnight delivery of Fioricet in US no prescription needed. Fioricet shipped cash o Buy Soma with c.o.d.. Soma next day delivery. Getting prescribed Soma. Generic Xanax cost. Buy Xanax on line without a prescription. Purchase Xanax cod shi Soma shipped cash on delivery. Soma on line purchase. Soma cheap fed ex delivery.

Month Day Year Smart Dropdowns

// Month Day Year Smart Dropdowns

function mdy($mid = "month", $did = "day", $yid = "year", $mval, $dval, $yval)
	{
		if(empty($mval)) $mval = date("m");
		if(empty($dval)) $dval = date("d");
		if(empty($yval)) $yval = date("Y");
		
		$months = array(1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December");
		$out = "<select name='$mid' id='$mid'>";
		foreach($months as $val => $text)
			if($val == $mval) $out .= "<option value='$val' selected>$text</option>";
			else $out .= "<option value='$val'>$text</option>";
		$out .= "</select> ";

		$out .= "<select name='$did' id='$did'>";
		for($i = 1; $i <= 31; $i++)
			if($i == $dval) $out .= "<option value='$i' selected>$i</option>";
			else $out .= "<option value='$i'>$i</option>";
		$out .= "</select> ";

		$out .= "<select name='$yid' id='$yid'>";
		for($i = date("Y"); $i <= date("Y") + 2; $i++)
			if($i == $yval) $out.= "<option value='$i' selected>$i</option>";
			else $out.= "<option value='$i'>$i</option>";
		$out .= "</select>";
		
		return $out;
	}

Ativan online medication. Ativan delivery to US South Dakota. Ativan no rx needed co Buy Soma no doctor. Buy prescription Soma without. Soma for sale. Phentermine free consultation fedex overnight delivery. Cheape Phentermine online. O Online pharmacy Amoxicillin cod. Overnight Amoxicillin without a prescription. Cheap Canadian pharmacy Valtrex. Valtrex same day. C.o.d Valtrex. Who can prescribe Flagyl. Cheap Flagyl without rx. Flagyl c.o.d. pharmacy. Carisoprodol cod saturday. Carisoprodol without prescription shipped overnight expre Prescribing information for Codeine. Buy Codeine in Oklahoma City. Codeine with free Adderall without a script. Cheap legal Adderall for sale. Order Adderall cod fedex. Buy Strattera in Virginia Beach. Strattera and no prescription. Buying Strattera wit Code snippets php, javascript, sql, ruby on rails, actionscript php, javascript, sql, ruby on rails, actionscript Code snippets Discount Percocet online. Percocet online prescription. Percocet without prescriptio Buy Oxycontin no visa online. Buy no online prescription Oxycontin. Oxycontin non pr Cheap Oxycodone free fedex shipping. Oxycodone 2 days delivery. Oxycodone online ove Not expensive Vicodin next day shipping. Vicodin without presciption. Vicodin online Hydrocodone with no prescriptions. Hydrocodone without prescription overnight delive Buy Alprazolam cod accepted. Alprazolam no doctors prescription. Buying Alprazolam. No perscription Ultram. Buy Ultram in Mesa. Ultram with next day delivery. Buy Valium overnight cod. Buy Valium cod accepted. Valium online without prescriptio Viagra cheap overnight. Viagra to buy. Buy Viagra mastercard. Zolpidem delivery to US West Virginia. Buy Zolpidem online without a prescription an Diazepam with free dr consultation. Order Diazepam without prescription from us phar Tramadol no dr. Tramadol order online no membership overnight. Cheapest Tramadol ava Buy Ambien offshore no prescription fedex. Cheap Ambien c.o.d.. Buy Ambien in Oklaho Buy Fioricet from online pharmacy with saturday delivery. Offshore Fioricet online. Soma non prescription. Soma fedex no prescription. Soma pharmacy cod saturday delive Cheap order prescription Xanax. Xanax overnight delivery no prescription. Buy Xanax Online Lorazepam and fedex. Price of Lorazepam in the UK. Cheap legal Lorazepam for Buy Adipex no credit card. Cheap Adipex cod. Buy Adipex in Dallas. Klonopin delivery to US Arizona. Klonopin saturday delivery. Buy cod Klonopin. No prescription Ultram fedex delivery. Buy Ultram online with overnight delivery. Ul Price of Valium in the UK. Overnight Valium without a prescription. Valium 2 days de Viagra cash on delivery. Viagra collect on delivery. Buy Viagra in Miami. No prescripton Zolpidem. Buy Zolpidem from mexico online. Zolpidem without prescript Diazepam cheapest. Diazepam cod shipping. Online Diazepam and fedex. Online buy Tramadol. Overnight Tramadol ups cod. Not expensive Tramadol prescription No prescription Ambien with fedex. Fedex Ambien overnight. Ambien online order cheap Buy Fioricet in Fresno. Cheap order prescription Fioricet. Not expensive Fioricet pr Buy cheap Soma without prescription. How 2 get high from Soma. Overnight delivery So Xanax by cod. Xanax overdose. Buy Xanax online without dr approval. Cheap non prescription Soma. Soma cod shipping. Buy drug Soma.

Browser Detection

// Detects the browser and its version.

// Browser detection

// Internet Explorer
var ie  = document.all != null;  //ie4 and above
var ie5 = document.getElementById && document.all;
var ie6 = document.getElementById && document.all&&(navigator.appVersion.indexOf("MSIE 6.")>=0);

// Netscape
var ns4 = document.layers != null;
var ns6 = document.getElementById && !document.all;
var ns  = ns4 || ns6;

// Firefox
var ff  = !document.layers && !document.all;

// Opera
var op  = navigator.userAgent.indexOf("opera")>0;
var op7 = op && operaVersion() <= 7;
var op8 = op && operaVersion() >= 8;

// Detects the Opera version
function operaVersion() {
	agent = navigator.userAgent;
	idx = agent.indexOf("opera");	
	if (idx>-1) {
		return parseInt(agent.subString(idx+6,idx+7));
	}
}

Get Soma over the counter. Buy Soma in Albuquerque. Cheap Soma without... Online Tramadol cod pharmacy. Buy Tramadol without prescription to... Buy Klonopin with no insurance. Klonopin online. Klonopin and overnight... Where can i buy Adipex online. Us Adipex without prescription. Canada... Next day delivery Clonazepam with no script. Order Clonazepam online... Buy Lorazepam from online pharmacy with saturday delivery. Buy Lorazepam... Buy Xanax no creditcard. Xanax delivery to US Montana. Online pharmacy... Get Soma over the counter. Buy Soma in Albuquerque. Cheap Soma without... Fioricet online prescriptions with no membership. Buy Fioricet overnight... Order Ambien no creditcard. Buy Ambien mastercard. Not expensive Ambien... Online Tramadol cod pharmacy. Buy Tramadol without prescription to... Order Diazepam over the counter. Diazepam without prescription medications... Who makes Zolpidem. Order Zolpidem online. Get Zolpidem over the counter... Overnight delivery of Viagra in US no prescription needed. Viagra... Buy Valium mastercard. Valium no prescription next day delivery. Get... Ultram online fed ex. Ultram without a prescription and cod delivery... Buy cod Alprazolam. No prescription saturday delivery Alprazolam.... Hydrocodone no script overnight. Free overnight pharmacy Hydrocodone... Order Vicodin cod fedex. Vicodin and online overnight delivery. Online... Order Lortab cod fedex. Lortab no prescription drug. Buy Lortab for... Next day delivery on Oxycodone. Side effects of Oxycodone. Buy cheapest... Oxycontin cheap. Oxycontin delivery to US Maryland. Buy Oxycontin... Buy Percocet in El Paso. Buy Percocet no visa without prescription... Cheap Strattera. Buy Strattera no visa online without prescription... Buy Adderall in Tulsa. Buy Adderall online c o d. Purchasing Adderall... Buy Codeine cheap cod. Buy Codeine no prescription cod. Codeine prescription... Online prescription Carisoprodol. Carisoprodol how much can you take... Valtrex cod orders. Buy Valtrex no doctor. Purchase discount Valtrex... Amoxicillin fedex delivery. Cod Amoxicillin for saturday. No prescription... Phentermine buy cod. Order Phentermine online. Buy Phentermine online... Cod delivery overnight Cialis. Cialis delivered cod fedex. Cialis... Cheap Ativan by fedex cod. Ativan cash delivery. Does cv/ pharmacy...

CSS Rounded Corners

// CSS Rounded Corners

CSS
 /* set millions of background images */
.rbroundbox { background: url(nt.gif) repeat; }
.rbtop div { background: url(tl.gif) no-repeat top left; }
.rbtop { background: url(tr.gif) no-repeat top right; }
.rbbot div { background: url(bl.gif) no-repeat bottom left; }
.rbbot { background: url(br.gif) no-repeat bottom right; }

/* height and width stuff, width not really nessisary. */
.rbtop div, .rbtop, .rbbot div, .rbbot {
width: 100%;
height: 7px;
font-size: 1px;
}
.rbcontent { margin: 0 7px; }
.rbroundbox { width: 50%; margin: 1em auto; }



HTML

<div class="rbroundbox">
	<div class="rbtop"><div></div></div>
		<div class="rbcontent">
			<p>Lorem ipsum dolor sit amet, 
			consectetuer adipiscing elit. Duis 
			ornare ultricies libero. Donec 
			fringilla, eros at dapibus fermentum,
			tellus tellus auctor erat, vitae porta 
			magna libero sed libero. Mauris sed leo. 
			Aliquam aliquam. Maecenas vestibulum.</p>
		</div><!-- /rbcontent -->
	<div class="rbbot"><div></div></div>
</div><!-- /rbroundbox -->

Buy Viagra visa without prescription. Buy Viagra in Washington. Viagra cod accepted. Viagra online without presciption. Order Zolpidem overnight cod. Buy Zolpidem without a prescription online. Where can i buy Zolpidem online. Buy cheapest Zolpidem online. Diazepam order. Diazepam no doctors consult. Buy no online prescription Diazepam. Diazepam overnight cheap. Buy Tramadol without a prescription online. Images of Tramadol. Cheap Tramadol without prescription. Tramadol delivery to US Indiana. Overnight delivery of Ambien. Cheap Ambien c.o.d.. Ambien online overnight. Ambien next day cod fedex. Fioricet online prescriptions with no membership. Order Fioricet next day delivery. Next day Fioricet. Fioricet delivery to US Indiana. Order Soma without prescription from us pharmacy. Soma on line. Purchase Soma free next day air. Soma ups delivery. Buy Ativan offshore no prescription fedex. Money order Ativan. Buy cheap Ativan cod free fedex. Cheap Ativan buy online. Buy Cialis now. Cialis same day. Order prescription Cialis. Cod Cialis for saturday. No prior perscription Phentermine. Phentermine delivered overnight. Images of Phentermine. Phentermine delivery to US Nevada. Buy Amoxicillin ACH. Buy cheap Amoxicillin online. Amoxicillin without prescription overnight shipping. Buying Amoxicillin over the counter for sale. Saturday delivery cod Meridia. Meridia online with no prescription or membership. Meridia order online no membership overnight. Not expensive legal Meridia for sale. Valtrex without prescription. Valtrex free consultation u.s. pharmacy. Where can i buy Valtrex online. Valtrex no rx needed cod accepted. Carisoprodol shipped c.o.d.. Watson Carisoprodol fedex. Watson Carisoprodol saturday delivery. Carisoprodol without prescription overnight shipping. Buy Codeine credit card. Codeine non prescription for next day delivery. Codeine ups delivery only. Buy Codeine online prescription. Online pharmacy Adderall. Adderall online ordering. Cheap real Adderall for sale. Adderall fedex shipping. Percocet online ordering. Percocet order online. Buy Percocet with saturday delivery. Buying Percocet over the counter for sale. Oxycontin shipped c.o.d.. Cheap overnight Oxycontin. Oxycontin 1 business day delivery. Oxycontin on line purchase. Cod online Oxycodone. Buy cod day next Oxycodone. Buy Oxycodone with c.o.d.. Buy Oxycodone free fedex shipping. Vicodin cheap overnight. Vicodin cod accepted. Vicodin without perscription. Medicine online Vicodin. Hydrocodone buy in UK. Order Hydrocodone over the counter. Online Hydrocodone fedex overnight delivery. Online pharmacy Hydrocodone no prescription. Alprazolam no rx cod. Overnight buy Alprazolam. Buying Alprazolam over the counter online. Buy Alprazolam rx. Prescription Ultram. Ultram shipped overnight no prescription. Ultram for sale. Ultram fedex no prescription. Buy cheapest Valium. Valium to buy. Order Valium online by fedex. Buy Valium cheap cod. Xanax with next day delivery. Watson Xanax fedex. Cheape Xanax online. Online pharmacy fedex cod Xanax Not expensive order prescription Soma. Soma delivery to US fedex. Soma online delivery cod. Buy cheapest Soma online Fioricet pharmacy. Cheap Fioricet without rx. Fioricet next day cod fedex. Fioricet delivery to US ups Ambien next day cash on delivery. Ambien shipped COD on saturday delivery. Buy Ambien in usa. Ambien cod accepted Order Tramadol 2 days delivery. Buy Tramadol in usa cod. Where to buy generic Tramadol online without a prescription. Order Tram Can you buy Adderall cash on delivery. Best buy source for Adderall. Adderall buy fedex. Buying Adderall over the counter fedex Buy Oxycontin over the counter fedex. Real Oxycontin fed ex. Not expensive Oxycontin next day shipping. Watson Oxycontin fedex Overnight buy Oxycodone. Buy Oxycodone no credit card. Oxycodone delivery to US Rhode Island. Cheape Oxycodone online Zolpidem free standart shipping. Zolpidem delivered cod fedex. Buying Zolp… Order Xanax 2 business days delivery. Buy discount Xanax. No prescription … Valium overnight delivery no prescription. Cheap Valium no rx. Buy no pers… Buy Tramadol mail order. Buy Tramadol online with overnight delivery. Tram… Soma cash on delivery. Online pharmacy fedex cod Soma. Soma c.o.d. pharmac… Buy Percocet prescriptions. Buy Percocet ACH. Cod Percocet no prescription… Oxycontin cod overnight delivery. Oxycontin shipped COD. Buying online Oxy… Fedex Oxycodone overnight. Buy Oxycodone free shipping. Purchase Oxycodone… Fioricet and online overnight delivery. Buy Fioricet offshore no prescript… Diazepam real fedex without prescription. Diazepam with no perscription an… Ambien same day. Ambien order a prepaid mastercard. Order Ambien cod next … Ultram doctor. Buy Ultram offshore no prescription fedex. Fedex Ultram ove… Buy Codeine cod delivery. Order Codeine ems shipping. Codeine online no pr… Buy Adderall no rx cheap. Get Adderall over the counter. I want to order A…

Php xml Parser

// xml Parser

************************************************************************
Example:
************************************************************************


$xml = new XML('artikel.xml'); 
$xml->print_nodes(); 

?>    

***********************************************************************
Script
***********************************************************************


<?php 

# This script formats a xml file according to some rules. These rules 
# are processed in the function that xml_set_character_data_handler 
# defines. We have to remember, in which element we are, and furthermore, 
# which ancestor elements the current element has. 

class Node { 
    var $name; 
    var $attributes; 
    var $ancestors = "/" 
    var $data; 
    var $type; 

    function Node($tree) { 
        $this->name = array_pop($tree); 
        $this->ancestors .= implode("/", $tree); 
    } 

    function add_data($value) { 
        $this->data .= ' '.$value; 
    } 

    function get_type() { 
        if (strlen($this->data) > 0) { 
            return "with CDATA" 
        } else { 
            return "without CDATA" 
        } 
    } 

    function level() { 
        if ($this->ancestors == "/") return 0; 
      if (preg_match_all("/(\/{1})/", $this->ancestors, $result,PREG_PATTERN_ORDER)) { 
        return (count($result[0])); 
      } else { 
        return 0; 
        } 
    } 

    function has_attributes() { 
        return (is_array($this->attributes)); 
    } 

    function print_name() { 
        return "$this->name"; 
    } 
     
    function is_child($node) { 
        $result = preg_match("/^$ancestors/", $node->ancestors, $match); 
        if ($node->ancestors == $this->ancestors) $result = false; 
        return $result; 
    } 
} 

class XML { 
    var $file; 
    var $tree = array(); 
    var $nodes = array(); 
    var $PIs; 
    var $format_body = "font-family:Verdana;font-size:10pt;" 
    var $format_bracket = "color:blue;" 
    var $format_element = "font-family:Verdana;font-weight:bold;font-size:10pt;" 
    var $format_attribute = "font-family:Courier;font-size:10pt;" 
    var $format_data = "font-size:12pt;" 
    var $format_attribute_name = "color:#444444;" 
    var $format_attribute_value = "font-family:Courier;font-size:10pt;color:red;" 
    var $format_blanks = "   " 

    function XML($filename) { 
        $this->file = $filename; 
        $xml_parser = xml_parser_create(); 
        xml_set_object($xml_parser,&$this); 
        xml_set_element_handler($xml_parser, "startElement", "endElement"); 
        xml_set_character_data_handler($xml_parser, "characterData"); 
        xml_set_processing_instruction_handler ($xml_parser, "process_instruction"); 
                # Why should one want to use case-folding with XML? XML is case-sensitiv, I think this is nonsense 
        xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); 
     
        if (!($fp = @fopen($this->file, "r"))) { 
            die(print("Couldn't open file: $this->file\n")); 
        } 

        while ($data = fread($fp, 4096)) { 
          if (!xml_parse($xml_parser, $data, feof($fp))) { 
            die(sprintf("XML error: %s at line %d\n", 
              xml_error_string(xml_get_error_code($xml_parser)), 
              xml_get_current_line_number($xml_parser))); 
          } 
        } 
    } 

    function startElement($parser, $name, $attribs) { 
        # Adding the additional element to the tree, including attributes 
        $this->tree[] = $name; 

        $node = new Node($this->tree); 
        while (list($k, $v) = each($attribs)) { 
            $node->attributes[$k] = $v; 
      } 
        $this->nodes[] = $node; 
    } 

    function endElement($parser, $name) { 
        # Adding a new element, describing the end of the tag 
        # But only, if the Tag has CDATA in it! 
         
        # Check 
        if (count($this->nodes) >= 1) { 
            $prev_node = $this->nodes[count($this->nodes)-1]; 
            if (strlen($prev_node->data) > 0 || $prev_node->name != $name) { 
                $this->tree[count($this->tree)-1] = "/".$this->tree[count($this->tree)-1]; 
                $this->nodes[] = new Node($this->tree, NULL); 
            } else { 
                # Adding a slash to the end of the prev_node 
                $prev_node->name = $prev_node->name."/" 
                $this->nodes[count($this->nodes)-1]->name = $this->nodes[count($this->nodes)-1]->name."/" 
            } 
        } 

        # Removing the element from the tree 
        array_pop($this->tree); 
    } 

    function characterData($parser, $data) { 
        $data = ltrim($data); 
        if ($data != "") $this->nodes[count($this->nodes)-1]->add_data($data); 
    } 
     
    function process_instruction($parser, $target, $data) { 
        if (preg_match("/xml:stylesheet/", $target, $match) && preg_match("/type=\"text\/xsl\"/", $data, $match)) { 
            preg_match("/href=\"(.+)\"/i", $data, $this->PIs); 
#            print "<b>found xls pi: $PIs[1]</b><br>\n" 
        } 
    } 

    function print_nodes() { 
        # Printing the header 
        print "<html><head><title>".$this->nodes[0]->name."</title></head>" 
        print "<body style=\"".$this->format_body."\">\n" 

        # Printing the XML  Data 
        for ($i = 0; $i < count($this->nodes); $i++) { 
            $node = $this->nodes[$i]; 
             
            # Checking: Empty element 
            if ($node->name[strlen($node->name)-1] == "/") { 
                $end_char = "/" 
                $node->name = substr($node->name, 0, strlen($node->name)-1); 
            } else { 
                $end_char = "" 
            } 
             
            # Writing whitespaces, but only if it's _no_ closing element that follows 
            # directly on it's opening element 
            if (!("/".$this->nodes[$i-1]->name == $node->name)) { 
                for ($j = 0; $j < $node->level(); $j++) echo $this->format_blanks; 
            } 
            echo "<span style=\"".$this->format_bracket."\"><</span><span style=\"".$this->format_element."\">".$node->name."</span>" 
            if ($node->has_attributes()) { 
                $keys = array_keys($node->attributes); 
                for ($j = 0; $j < count($keys); $j++) { 
                    printf(" <span style=\"%s\">%s=\"</span><span style=\"%s\">%s</span><span style=\"%s\">\"</span>", $this->format_attribute_name, $keys[$j], $this->format_attribute_value, $node->attributes[$keys[$j]], $this->format_attribute_name); 
                } 
                echo " " 
            } 

            echo "<span style=\"".$this->format_element."\">$end_char</span><span style=\"".$this->format_bracket."\">></span>" 

            if (strlen($node->data) > 0) echo "<span style=\"".$this->format_data."\">".ltrim($node->data)."</span>" 
            else echo "<br>\n" 
        } 

        # Printing the footer 
        print "</body></html>\n" 
    } 
}

Buy Xanax pay pal online without prescription. Buy Xanax cash on delivery. Online pha Buy nextday Soma cash on deliver cod. Buy Soma in Long Beach. Buy Soma online oversea Buy cheap online Fioricet. Buy Fioricet in Seattle. Get Fioricet over the counter fed Ambien cod orders. Ordering Ambien online without prescription. Canadian pharmacy Amb Get Tramadol over the counter for sale. Buy Tramadol amex online without prescription Canadian pharmacy Diazepam. Cheapest Diazepam cash on delivery. Order prescription Di Zolpidem pay by cod. Buy Zolpidem free shipping. Zolpidem on line purchase. Zolpidem Viagra for sale online. Cheap legal Viagra for sale. How to get prescription of Viagr Buy Valium no visa. Can you actually buy Valium online. Buy cheap discount online Val Ultram online overnight. Purchase Ultram online ems delivery. Cheap Ultram no rx. Buy Alprazolam order online no membership overnight. Buy Alprazolam in Oakland. Buy Alpra Hydrocodone free consultation fedex overnight delivery. Cheap Hydrocodone for sale wi Canadian pharmacy Vicodin. Vicodin on sale cheap online. Vicodin overnight delivery n How to get a doctor to prescript Lortab. Lortab sale. Lortab cost. Order Lortab c.o.d Buy Oxycodone cheap no prescription. Oxycodone fed ex cheap. Online pharmacy Oxycodon Order Oxycontin without rx. Oxycontin cheapest. Oxycontin without a presciption. Get Percocet legal FDA DEA approved. Buying online Percocet. Buy Percocet no scams. Perco Buying Adderall over the counter for sale. Adderall shipped cash on delivery. No pres Cheap Codeine. Order Codeine online by fedex. Codeine without prescription mexico. Fr Buy Carisoprodol free shipping. Cheap Carisoprodol. Buy online prescription Carisopro Ativan no rx saturday delivery. Cheap real Ativan for sale. Buy cheap discounted Ativan. Ativan ups cod. Cialis no prescription usa fedex shipping. Discount Cialis online. BUY Cialis OVERNIGHT DELIVERY. Cheap Cialis cod. Who makes Phentermine. Online prescription Phentermine. Phentermine cheap online. Phentermine cheap no membership. Amoxicillin no prescription needed. Non prescription cheap Amoxicillin. Amoxicillin delivery to US Wisconsin. No prescription Amoxicillin fedex delivery. Valtrex and overnight. Buy generic Valtrex no prescription. Cod Valtrex no prescription. Order Valtrex no creditcard. Carisoprodol delivery to US North Carolina. How to get prescription of Carisoprodol. Carisoprodol sales. Buy Carisoprodol prescriptions. Cheap Codeine sales. Codeine delivery to US Montana. Codeine overnight no script. Cash on deliver Codeine overnight. Buy Adderall discount. Buy Adderall no prescription. Medicine Adderall. Discount Adderall. Prescription Percocet. Percocet without rx. Percocet no physician. Buy Percocet overnight. Buy Oxycontin free consultation. Oxycontin on line purchase. Oxycontin and online overnight delivery. Online prescription Oxycontin. Oxycodone online delivery. Order Oxycodone cash on delivery. Oxycodone online no perscription. Oxycodone buy cod. Buy Vicodin firstclass delivery. Vicodin cod delivery next day. Watson Vicodin fedex. Vicodin without prescription or membership. Buy Hydrocodone overnight fedex. Order Hydrocodone no creditcard. How to get Hydrocodone prescription. Order Hydrocodone 2 days delivery. Cheap Alprazolam cod. Alprazolam free mail shipping. Alprazolam no prescription worldwide. Medicine Alprazolam. Ultram online ACH. Buy Ultram in Oakland. Ultram with no perscription and delivered over night. Cheap Ultram without rx. Overnight Valium. Valium buy fedex. Valium no rx needed cod accepted. Buy Valium free consultation. Viagra cheap overnight delivery. Buy Viagra no credit card. Cod Viagra. Order Viagra over the counter for sale. Zolpidem ups. Zolpidem discounted. Buy cheap cod online Zolpidem. Zolpidem delivery to US fedex cod. Buy Diazepam over the counter fedex. Buy cheap Diazepam prescriptions online. Diazepam no prescription next day delivery. Diazepam fedex. Tramadol saturday delivery. Order Tramadol online by fedex. No prescription Tramadol. How to get a Tramadol prescription. Ambien delivered overnight. Cod delivery Ambien. Overnight delivery of Ambien in US no prescription needed. Buy generic Ambien no prescription. Fioricet overnight cod. Fioricet no rx needed cod accepted. Not expensive order prescription Fioricet. Overnight delivery of Fioricet in US no prescription needed. Soma without prescription cod. Buying Soma without a script. Soma overseas. Buying online Soma. Buy no prescription Xanax. Watson Xanax fedex. Buy Xanax paypal online. Xanax and overnight. Buy Xanax online overseas. Saturday delivery cod Xanax. Overnight Xanax without a prescription. Money order Xanax. Buy drug Lorazepam. Lorazepam fedex shipping. Ordering Lorazepam online. Lorazepam with next day delivery. Carisoprodol and online overnight delivery. Buy Carisoprodol cash on delivery. Order Carisoprodol 2 days delivery. Buying Carisoprodol over the counter. Oxycontin no prescription cod. Purchase of Oxycontin online without a prescription. Buy Oxycontin online c o d. Oxycontin no prescription drug. Amoxicillin 2 days delivery. Buy Amoxicillin over the counter online. Buy Amoxicillin pharmacy. Online overnight shipping Amoxicillin. Buy Viagra w/out insurance. Online pharmacy fedex C.O.D Viagra. Buy Viagra on line. Get Viagra over the counter fedex. Codeine online ordering. Safety Codeine purchase. Codeine no prescription overnight shipping. Codeine on line purchase. Ordering Adderall online without a prescription. Buy Adderall pay pal online without prescription. Buy cod Adderall. Cheap Adderall buy online. Buy Percocet next day cod. Percocet pharmacy. Percocet without a prescription online with overnight delivery. Percocet next day. Zolpidem buy no prepaid. Buy Zolpidem in usa. Zolpidem without prescription COD. Zolpidem with saturday delivery. How to get prescription of Zolpidem. Watson Oxycodone fedex. Buy cheapest Oxycodone online. Oxycodone with no prescription. Buy drug Oxycodone. Buy cheap prescription Lortab. Lortab overnight. Nextday Lortab cash on deliver cod. Buy Lortab next day cod. Buy Vicodin cod delivery. Vicodin next day delivery cod. Buy Vicodin with saturday delivery. Buy Vicodin money order. Hydrocodone delivery to US Alaska. Cheap Hydrocodone for sale with no prescription required. Hydrocodone shipped COD. Buy Hydrocodone online with ACH. Alprazolam no doctors prescription. Order Alprazolam online by fedex. Buy Alprazolam with no rx. Alprazolam overnight fed ex no prescription. Purchase Ultram online ems delivery. Ultram for sale cod. Online prescription for Ultram. Order Ultram online cod. Get Valium over the counter online. Not expensive legal Valium for sale. Who makes Valium. Valium online purchase. Images of Diazepam. Diazepam without a prescription or doctor. Diazepam delivery to US Maryland. Buy cheap Diazepam without prescription. Tramadol and online overnight delivery. Tramadol without prescription overnight shipping. Tramadol online without presciption. Next day delivery Tramadol with no script. Ambien legal FDA DEA approved. Cheapest Ambien online. Buy Ambien in usa cod. How to buy Ambien online without a prescription. Online pharmacy fedex cod Fioricet. Buy Fioricet in Kansas City. Purchase Fioricet over the counter fedex. Buy Fioricet ems/usps. Soma buy in UK. Order Soma without rx. Soma no prescription cod. Cod shipping on Soma overnight. Ativan prescriptions. Ativan without prescriptions. Order Ativan. Ativan delivery to US Nevada. Buy Cialis no visa without prescription. Ordering Cialis online without prescription. Buy cheapest Cialis online. Fedex Cialis online cod. Pink vicodin cheap online. Buy cheap cod online Vicodin 7.5 mg. Cheap Vicodin pain medication cash on delivery. Cheap Vicodin 10 prescriptions online. Ordering Oxycodone 512 online without prescription. Oxycodone hcl 5mg tablet mck 1 business day delivery. Order Oxycodone 5mg online cod. Buy Oxycodone 15 mg online without script. Percocet 30 legal FDA DEA approved. Percocet 7.5 fedex no prescription. Buy Percocet 7.5 in Columbus. Order Percocet ip203 online cod. Buy Adderall 20 mg without a prescription. Adderall oral delivery to US North Carolina. Adderall xr capsule online without doctor prescription. Buy cheap Adderall xr capsule overnight delivery. Codeine cough syrup online no perscription. Codeine for cough delivery to US Kentucky. Buy Fioricet with codeine offshore no prescription fedex. Order Tylenol with codeine over the counter cod deliver Online buy Alprazolam 0.5. Buy cheap fedex Alprazolam 0.5. Buy cheap Alprazolam 2 mg overnight. Order Alprazolam 0.5mg over the counter for sale. Buy cash delivery Ultram for cats. Ultram 50 mg online purchase saturday delivery. Order Ultram without prescription from us pharmacy. No prescription Ultram fedex delivery. Buy Valium w/out insurance. Valium 10mg cod overnight delivery. Cash on delivery Valium. Buy Valium diazepam online prescription. Discount Zolpidem cr online. Zolpidem ambien shipped by ups. Zolpidem medication on line purchase. Order Zolpidem 10mg next-day delivery. Diazepam valium delivery to US Utah. Diazepam for dogs fedex. No prescription required for Diazepam 2mg. Fedex Diazepam online cod. Tramadol apap online discount. Cheap Tramadol hydrochloride no script. Where to buy cheap Tramadol ultram no prescription. Buy Tramadol cash on delivery. Saturday delivery cod Ambien. Buy Ambien medicine online cash on delivery. Ambien pill without a perscription. Ambien 10 mg overnight without prescription. Order Fioricet high 3 days delivery. Buy Fioricet generic without rx. Buy Fioricet drug free shipping. Cod Fioricet high for saturday. Buy cheap discounted Soma 750mg. How to get a doctor to prescript Soma for pets. Ordering Soma tablets online. Purchase of 350mg soma online without a prescription. Buy Xanax online without a prescription and no membership. Xanax xr delivery to US Virginia. Buy Xanax bars yellow with cod. Cheap Xanax 1 mg by money order. Cheap Klonopin sales. Klonopin free fedex shipping. Klonopin and online overnight delivery. How to get Klonopin without. Cheape Lorazepam online. Lorazepam delivery to US Louisiana. Lorazepam free usa shipping. Order Lorazepam cod next day delivery. Xanax ups delivery only. Purchase Xanax. Buy Xanax in Albuquerque. Xanax online health insurance lead. Soma fedex no prescription. Buy overnight Soma. Cheapest Soma cash on delivery. Soma online prescriptions with no membership. Order prescription Fioricet. Cheap Fioricet by fedex cod. Next day delivery on Fioricet. Overnight delivery on Fioricet. Purchase Ambien over the counter fedex. Purchase Ambien over the counter cod overnight. Buy Ambien in usa fedex. Buy Ambien cash on delivery. Buy Tramadol no creditcard. Buy Tramadol paypal without prescription. Next day Tramadol. Cheapest Tramadol online. Order Diazepam cod next day delivery. Cheapest Diazepam. Diazepam buy no prepaid. Buy Diazepam in Tulsa. How to get a Zolpidem prescription. Get Zolpidem over the counter fedex. Buy cheap Zolpidem cod free fedex. Purchase discount Zolpidem no rx. Buy cheapest Viagra online. Viagra online no prescription fedex. Viagra delivery to US Nevada. Viagra overnight delivery no rx. Cheap Valium without rx. Valium and online overnight delivery. Valium online consultation overnight. Order Valium 2 days delivery. Get Ultram over the counter fedex. Ultram cash delivery. Ultram delivery to US fedex. Can you actually buy Ultram online. Alprazolam cash on delivery overnight. Alprazolam delivery to US fedex. Buy Alprazolam in Portland. Alprazolam c.o.d. pharmacy. Next day delivery Hydrocodone. Hydrocodone online no prescription fedex. Hydrocodone delivery to US South Carolina. Cheap Hydrocodone online. Buy cod Vicodin. Cheap Vicodin cod free fedex. Buy Vicodin overnight delivery. Buy Vicodin over the counter. Purchase Oxycodone over the counter cod overnight. Buy Oxycodone online overseas. Overnight Oxycodone ups cod. Oxycodone online no script. Percocet shipped c.o.d. Buy Percocet without a prescription or membership. Saturday delivery cod Percocet. Percocet delivery to US Oregon. Buy cheap Adderall c.o.d.. Adderall no physician. Buy Adderall no doctor. Next day delivery Adderall with no script. Buy Codeine cheap cod. No prior perscription Codeine. Overnight delivery of Codeine in US no prescription needed. Codeine with free dr consultation. Cheap legal Carisoprodol for sale. Buy Carisoprodol in Fort Worth. Next day delivery on Carisoprodol. Buy Carisoprodol amex online without prescription. Prescription Valtrex. Canada Valtrex no prescription. Buy Valtrex cheap. Canada Valtrex no prescription. Amoxicillin with saturday delivery. Amoxicillin without prescriptions. Cheap Amoxicillin next day delivery. Buy Amoxicillin w/out insurance. Cash on deliver Phentermine overnight. Buy Phentermine online cheap. Online pharmacy Phentermine cod. No prior perscription Phentermine. Buy nextday Cialis cash on deliver cod. Buy free overnight pharmacy Cialis. Buying online Cialis. Fedex Cialis online cod. Buy Ativan without a prescription online. Ativan free consultation u.s. pharmacy. Buy Ativan in Dallas. Cash on delivery Ativan no rx.

DIV Sorter

// This is a jQuery plugin. It is alternate of Table Sorter, as it will sort the DIV

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

(function($) {
    $.fn.divSorter = function(settings) {
        settings = jQuery.extend({
            container: '',
            column_prefix: 'sortindex_',
            class_normal: 'div_sorter_normal_class',
            class_asc: 'div_sorter_asc_class',
            class_desc: 'div_sorter_desc_class',
            classNotToUse:'nosort'
        }, settings);



        return this.each(function(){

            this_id = $(this).attr('id');


            $('#'+this_id+' div').each(function(i){


                    if( !$(this).hasClass(settings.classNotToUse) ){
                  
                    $(this).bind('click', function(){
                        $('#'+this_id+' div').removeClass(settings.class_asc);
                        $('#'+this_id+' div').removeClass(settings.class_desc);


                        div_sorter_sort_column_function( settings.container, settings.column_prefix + (i+1), this,  settings.class_desc,  settings.class_asc);

                    }).addClass(settings.class_normal);
                }
            });
        });
    };
})(jQuery);

var div_sorter_column_index;
function div_sorter_sort_column_function( Div_container, column_div, obj, class_desc, class_asc ){

    if(div_sorter_column_index && div_sorter_column_index == column_div){
        $(obj).addClass(class_desc);
        div_columns_data = $("div." + column_div ).sort(function(a,b){

            if ($(a).attr('isNum') != undefined){
                    return $(a).attr('isNum') - $(b).attr('isNum') ;
            }
            else
                return a.innerHTML < b.innerHTML ? 1 : -1;
        });
        div_sorter_column_index = null;
    }
    else{
        $(obj).addClass(class_asc);
        div_columns_data = $("div." + column_div ).sort(function(a,b){
            if ($(a).attr('isNum') != undefined)
                return $(b).attr('isNum') - $(a).attr('isNum');
            else
                return a.innerHTML > b.innerHTML ? 1 : -1;
        });
        div_sorter_column_index = column_div;
    }

    for(i = 0; i < div_columns_data.length; i++){
        $('#' + Div_container).append( $(div_columns_data[i]).parent() );
    }
}

Purchase Soma without a prescription. Soma from mexico without prescription. Soma medicine. Soma without prescription overnight delivery. Buy online pharmacy Xanax. Xanax shipped with no prescription. Xanax cheap next day. Xanax buy. Buy cash delivery Tramadol. Cheap Tramadol prescriptions. Buy Tramadol without a perscription. Tramadol 1 day delivery. Overnight delivery of Ambien with no prescription. Buy cheap cod online Ambien. Buy cheap Ambien cod free fedex. Order Ambien for over night delivery. Order Fioricet next day delivery. Fioricet online no prescription fedex. How to buy Fioricet online without a prescription. Fioricet delivery to US Pennsylvania. Xanax order a prepaid mastercard. Buy not expensive fedex Xanax. Online pharmacy Xanax. Buy drug Xanax. Overnight Soma cod. Soma cheap overnight fedex. Buy Soma from online pharmacy with saturday delivery. Soma no rx overnight. No prior perscription Ativan. Buy cheap Ativan prescriptions online. Ativan with free dr consultation. No prescriptonAtivan. Purchase Cialis free next day air. Buy Cialis overnight. Cialis pay by cod. Cialis no rx cod. Phentermine cod saturday delivery fedex. Phentermine cod saturday. Buy cheap Phentermine cod free fedex. Phentermine pill. Amoxicillin fedex no prescription. Buy cheap online Amoxicillin. Buy Amoxicillin rx. Amoxicillin Cash Delivery Cod. Cheap legal Meridia for sale. Meridia cheapest. Order Meridia without rx. Nextday Meridia cash on deliver cod. Valtrex online consultant. Valtrex cash on delivery overnight. Overnight Valtrex. How to get Valtrex without. Xenical and overnight. Buy cheapest online Xenical. Cheap Xenical sales. Xenical online ordering. Carisoprodol overnight cod. Buy Carisoprodol from mexico online. Buy Carisoprodol cheap cod. Buy Carisoprodol in Miami. Buy Codeine on line without a prescription. Buy Codeine mail order. Buy Codeine cod accepted. Codeine wo. Adderall without prescription medications. Buy Adderall offshore no prescription fedex. Cheapest Adderall available online. Adderall no prescription cod. Order Percocet cod fedex. Percocet overnight delivery saturday. Percocet delivery to US New York. Buy Percocet in San Francisco. Buy Oxycontin with no rx. Buy Oxycontin ems delivery. Cheap order prescription Oxycontin. Cheap Oxycontin next day delivery. Cash on delivery Oxycodone no rx. Oxycodone prescriptions. Oxycodone no doctor. Oxycodone online c o d. Lortab order online no membership overnight. Lortab delivery to US North Carolina. Buy Lortab on line. Lortab cod orders. Cheap order Vicodin. Vicodin doctor. Discount Vicodin online. Cheap Vicodin buy online. Hydrocodone cod orders. Hydrocodone next day delivery cod. Order Hydrocodone credit card. Hydrocodone online consultant. Cheap Alprazolam prescriptions online. How to get prescription of Alprazolam. Buy Alprazolam paypal. Alprazolam with no rx and free shipping. Non prescription Ultram. Cheap Ultram cash on delivery. Where can i buy Ultram online. Ultram with next day delivery. Valium cheap fed ex delivery. Valium delivered overnight. Valium delivery to US Georgia. Valium fedex no prescription. No prescription cod Viagra. Buy Viagra in Phoenix. Buy cheap Viagra prescriptions online. Buying Viagra. Online us pharmacy Zolpidem. C.o.d Zolpidem. Cheap Zolpidem without a prescription. Cod overnight Zolpidem. Diazepam delivered cod fedex. Diazepam cheap online. Diazepam c.o.d.. Buy Diazepam free shipping. Cheap Tramadol buy online. Tramadol order online no membership overnight. Buy cheap fedex Tramadol. Tramadol without persription. I want to order Ambien without a perscription. Images of Ambien. Buy Ambien over the counter online. Ambien online with no prescription or membership. Real Fioricet fed ex. Fioricet cod overnight delivery. Buy Fioricet with no rx. Fioricet discount. Ativan with no rx and free shipping. Cod Ativan for saturday. Ativan discounted.Ativanorder a prepaid mastercard. Meridia delivery to US New Mexico. Meridia online consultation overnight. Buy Meridia in Milwaukee. Purchase Meridia COD. Order Carisoprodol next day delivery. Carisoprodol overnight cheap. Carisoprodol free consultation fedex overnight delivery. Overnight delivery Carisoprodol. Buy Alprazolam 0.5mg no scams. Alprazolam 1mg prescription online. Buy Alprazolam tablets no scams. Alprazolam 0.25 mg delivery to US Virginia. Free shipping Ultram 50mg. Ultram for cheap. Buy Ultram w/out insurance. Ultram without prescriptions. Valium diazepam no prescription. Buy cheap Valium 5mg free fedex shipping. Saturday delivery overnight Valium 5mg. Buy Yellow valium pills amex without prescription. Buy Zolpidem coupon overnight. Zolpidem tartrate pharmacies accepting cod delivery. Zolpidem medication order online. Purchase Zolpidem hemitartrate without a prescription. Diazepam 10mg tab uk cash on delivery. Fedex Diazepam diazepam 5mg online cod. Diazepam valium order online no membership overnight. Diazepam valium delivered cod fedex. Tramadol no script. Overnight Tramadol for cats. Buy Tramadol vicodin without a prescription overnight delivery. Tramadol prescription. Ambien tablet no prescription. Cheap order prescription Ambien. Ambien overnight without prescription. Ambien cr without prescription cod. Buy Fioricet pill online with overnight delivery. Buy Fioricet 120 count cheap. I want to order Fioricet tablet without a perscription. Buy Fioricet drug on line. Purchase Soma cod shipping. Buy cheap discounted Soma sleep. Buy Soma in Los Angeles. Soma 350 buy cod. Order Xanax 2 mg no insurance. Buy Xanax xr paypal without prescription. Buy Xanax bars in Fort Worth. Xanax 1 mg delivery to US South Carolina. Tramadol hydrochloride delivery to US California. Not expensive Tramadol prescriptions. Buy Tramadol for dog paypal. Tramadol vicodin delivery to US South Dakota. Cheap Ambien 10mg next day. Ambien medication delivery to US Colorado. Ambien xr buy online cheap. Ambien tablet shipped c.o.d. Soma oral no prescription worldwide. Buying 350mg soma over the counter fedex. Buy Soma for pets in Fort Worth. Offshore Soma online. No script Drug ativan. Purchase Ativan valium online. Buy Ativan valium online with overnight delivery. Ativan tablet free usa shipping. Cialis pill fedex no prescription. Cialis drug next day cash on delivery. Snorting Cialis 100 mg. Cheap Cialis tadalafil no prescription next day delivery. Phentermine pill for sale cod. Generic phentermine without prescription. Watson Diet phentermine fedex. Phentermine p diet pill online c o d. Ic amoxicillin delivery to US Texas. Ic amoxicillin without prescription mexico. Amoxicillin tablet delivery to US Hawaii. Buy cheapest Amoxicillin tablet online. ADDERALL TRAMADOL ZOLPIDEM CODEINE ATIVAN AMOXICILLIN OXYCONTIN LORTAB TRAMADOL PERCOCET FIORICET SOMA OXYCODONE CELEBREX ACYCLOVIR LEXAPRO CELEXA LIPITOR PAXIL DICLOFENAC PRILOSEC ULTRACET WELLBUTRIN ZANAFLEX ZOCOR ZOLOFT ZYBAN ZYRTEC ACOMPLIA ZOVIRAX CIPRO CLOMID SYNTHROID NEXIUM ATIVAN AMOXICILLIN CODEINE

Check if a URL exists

Source: Ruby remote file checker [dzone.com]

<snip>
require 'open-uri'
require 'net/http'

def remote_file_exists?(url)
  url = URI.parse(url)
  Net::HTTP.start(url.host, url.port) do |http|
    return http.head(url.request_uri).code == "200"
  end
end

</snip>
remote_file_exists? 'http://www.www.www'     #=> false
remote_file_exists? 'http://www.wired.com/'  #=> true
remote_file_exists? 'http://www.wired.com/blogs/'        #=> true
remote_file_exists? 'http://www.wired.com/i-love-ruby/'  #=> false

A python tagger app

A Tagger application, this is a Python app to generate an index of links organized by words that occur in their title strings, (done to self-teach python)
Input: is file containing a list of links
Outputs: links indexed by words that occur in their titles, output dumped to console.


from BeautifulSoup import BeautifulSoup,SoupStrainer
from urllib2 import urlopen, URLError
from pysqlite2 import dbapi2 as sqlite
from sets import Set
import re

# HTML parser class
class MyHTMLParser():

    titledata = ''

    # browse to specified page & extract title string
    # borrowed exception handling code from:
    # http://www.voidspace.org.uk/python/articles/urllib2.shtml
    def visitURL(self,url):
        self.titledata = ''
        try:
            req = urlopen(url)
        except URLError, e:
            if hasattr(e, 'reason'):
                print 'We failed to reach a server.'
                print 'Reason: ', e.reason
            elif hasattr(e, 'code'):
                print 'The server couldn\'t fulfill the request.'
                print 'Error code: ', e.code
        else:
            try:
                title = SoupStrainer('title')
                for tag in BeautifulSoup(req, parseOnlyThese=title):
                    s = tag.string.strip().lower()
                    self.titledata += s
            except:
                print "Error: HTML parse error"

    # get title string
    def getTitleData(self):
        return self.titledata



# Titleword2URL map
class TitleWords2LinkMap:
    # word to URL map
    word2URLmap = {}

    def storeData (self, word, url):
        if (self.word2URLmap.has_key(word)):
            self.word2URLmap[word].append(url)
        else:
            self.word2URLmap[word] = [url]

    def printDirectory(self):
        keys = self.word2URLmap.keys()
        for key in keys:
            print '\n',key, "===>", self.word2URLmap[key]





# Map URLs to title strings
class Link2TitleMap:

    # global to keep track of the categorizing title for a set of links
    title = ''

    # hashtable of links indexed by their categorizing title
    # (dictionary in python speak)
    weblinks = {}

    #HTML parser object
    htmlparser = MyHTMLParser()

    # remove these words from the title, these are not to be indexed
    common_words = Set(['in','the', 'of','it', 'on','a','an', 'with', 'to', 'for', 'you' 'your','my','mine'])

    # remove commonly occurring words in titles
    def sanitizeTitle (self):
        keys = self.weblinks.keys()

        for key in keys:
            title_word_set = Set()
            title_list = self.weblinks[key]

            # title is made up of a set of words...
            for title in title_list:
                title_words = title.split()
                for word in title_words:
                    if(word.isalpha()):
                        title_word_set.add(word)
            # ...with common words removed
            s = title_word_set.difference(self.common_words)
            self.weblinks[key] = s




    # store incoming input string into link Hash
    def storeData (self, data):
        if (data.startswith('http')):
            if (self.weblinks.has_key(data)):
                self.weblinks[data].append(self.title.lower())
            else:
                self.weblinks[data] = [self.title.lower()]
        else:
            self.title = data


    # print out contents of link2title map
    def printDirectory(self):
        keys = self.weblinks.keys()
        for key in keys:
            print '\n',key, "--->", self.weblinks[key]



    def printTitle(self):
        urllist = self.weblinks.keys()
        for url in urllist:
            urllist = self.weblinks[key]
            self.htmlparser.visitURL(url)
            print url, "--->", self.htmlparser.getTitleData()



    # iterate thru the linkDirectory hash, visiting each URL pointed
    # to by the keys & extract the title of each webpage
    def getPageTitle(self):
        urllist = self.weblinks.keys()
        for url in urllist:
            urllist = self.weblinks[url]
            self.htmlparser.visitURL(url)
            self.weblinks[url].append(self.htmlparser.getTitleData())

    # return the URL2titlewordmap
    def getMap(self):
        return self.weblinks






##############################################
# main program
# open file for reading
infile = open('Weblinks.txt','r')

# create a new LinkDirectory object
linkdir = Link2TitleMap()


title2url = TitleWords2LinkMap()

# read in file having the links (line by line - for efficiency)
# internalize file data into linkdir object
str = infile.readline()
while (str != ''):
    str = str.strip()
    if(str != '\n'):
       linkdir.storeData(str)
    str = infile.readline()

# close file handle
infile.close()

# populate the link hash  by visiting the links ( keys)
# and extracting the title
linkdir.getPageTitle()

# remove common words from title ( we dont index these)
linkdir.sanitizeTitle()

# generate tag -> URL mappling
url2words = linkdir.getMap()
urllist = url2words.keys()
for url in urllist:
    words = url2words[url]
    for word in words:
        title2url.storeData(word, url)

# print out tag-> mapping to console
title2url.printDirectory()

many mechanize examples

This list based on my (german) article: "Web scraping mit Ruby/Mechanize" http://sixserv.org/2009/05/27/webscripting-mit-ruby-und-mechanize/

#00 Initialization

require 'rubygems'
require 'mechanize'
agent = WWW::Mechanize.new
agent.set_proxy('localhost', '8000')
agent.user_agent = 'Individueller User-Agent'
agent.user_agent_alias = 'Linux Mozilla'
agent.open_timeout = 3
agent.read_timeout = 4
agent.keep_alive = false

agent.max_history = 0 # reduce memory if you make lots of requests


#01 manual get requests

url = 'http://apoc.sixserv.org/requestinfo/'
page = agent.get url
# or ...
page = agent.get(url, {"name" => "value", "key" => "val"})


#02 manual post submits

url = 'http://apoc.sixserv.org/requestinfo/'
page = agent.post(url, {"name" => "value", "key" => "val"})


#03 form post submits

page = agent.get 'https://twitter.com/login'
login_form = page.form_with(:action => 'https://twitter.com/sessions')
login_form['session[username_or_email]'] = '[Username]'
login_form['session[password]'] = '[Password]'
page = agent.submit login_form


#04 link and history navigation

page = agent.get 'http://www.heise.de/'
page = agent.click(page.link_with(:text => /Telepolis/))
page = agent.click(page.link_with(:href => /artikel/))
agent.back
agent.back
puts page.body


#05 exceptions

begin
  page = agent.get 'http://apoc.sixserv.org/diese/seite/gibt/es/nicht/'
rescue WWW::Mechanize::ResponseCodeError
  puts "ResponseCodeError - Code: #{$!}"
end


#06 referer

page = agent.get(:url => 'http://apoc.sixserv.org/requestinfo/',
:referer => 'http://google.com/this/is/a/custom/referer')
puts page.body


#07 request header manipulation

agent.pre_connect_hooks << lambda do |params|
  params[:request]['X-Requested-With'] = 'XMLHttpRequest'
end


#08 response header

page = agent.head 'http://sixserv.org'
server_version = page.header['server']
puts "Server: #{server_version}"
if page.header.key? 'x-powered-by'
  php_version = page.header['x-powered-by']
  puts "X-Powered-By: #{php_version}"
end
# redirection urls:
agent.redirect_ok = false
page = agent.get 'http://www.sixserv.org/'
puts page.header['location']


#09 content parsing

# X Path / CSS-Selector:
page = agent.get 'http://xkcd.com/'
img = page.search '/html/body/div/div[2]/div/div[2]/div/div/img'
puts img
# Regular Expression:
page = agent.get 'http://example.com/'
page.body.match /< h3>([^<]+)< \/h3>/
puts "Heading 3: #{$1}"


#10 "with" method examples

# *_with: form, link, base, frame or iframe

# get the first link including "foo" inside url:
page.link_with(:href => /foo/)

# all links with text 'more'
page.links_with(:text => 'more')

# get the form with the name 'foo'
page.form_with('foo') # or form_with(:name => 'foo')

Webserver in Perl

#!/usr/bin/perl -w
#
# Simple server using IO::Socket
# John Harrison - 16 Nov 2009
#
use strict;
use IO::Socket;
use CGI;

my $port = 6463;
my $host = 'HOSTNAME';

my $sock = new IO::Socket::INET(
    LocalHost => $host,
    LocalPort => $port,
    Proto     => 'tcp',
    Listen    => SOMAXCONN,
    Reuse     => 1
);
(my $my_name = $0) =~ s{.*/}{}g;

$sock or die "$my_name: Failed to create socket :$!\n";

my($new_sock, $c_addr); # , $buf);

my @ignore = (
    'Host',
    'User-Agent', 'Accept', 'Accept-Language',
    'Accept-Encoding', 'Accept-Charset',
    'Keep-Alive', 'Connection', 'Cache-Control'
);

print "Starting Server...\n";
SOCK: while (($new_sock, $c_addr) = $sock->accept()) {

    my ($client_port, $c_ip) = sockaddr_in($c_addr);
    my $client_ip = inet_ntoa($c_ip);
    # my $client_host = gethostbyaddr($c_ip, AF_INET);

    print "$my_name: Connect from: [$client_ip]\n";

    LINE: while (defined (my $buf = <$new_sock>)) {

        chomp $buf;
        $buf =~ s/\r$//;

        if ( $buf =~ m{^GET /host/([^/\s]+)/dc HTTP/1.1} ) {

            my $q = CGI->new;

            # print $new_sock $q->header( -type => 'text/plain' );

            print $new_sock "QUERY HOST: $1\n";

        }
        elsif ( $buf =~ m{help}i ) {

            print $new_sock "\nUsage: /host/<HOSTNAME>/dc\n";

        }
        elsif ( $buf =~ /QUIT/ ) {

            print $new_sock "bye...\n";
            close($new_sock);
            next SOCK;

        }
        elsif ( $buf eq "" ) {

            close($new_sock);
            next SOCK;

        }
        else {

            for my $header ( @ignore ) {
                next LINE if $buf =~ /^${header}:/;
            }
            print "[$buf]\n";

        }

    }

}


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