#!/usr/bin/perl use strict; use CGI qw/:standard :html3 *table/; use LWP::UserAgent; my $scriptname=$ENV{'SCRIPT_NAME'}; my $radio=(param('RadioGroup1'))?param('RadioGroup1'):""; my $select=(param('select'))?param('select'):""; my $textfield=(param('textfield'))?param('textfield'):""; my $keyword=(param('keyword'))?param('keyword'):""; my $excludeorg=(param('excludeorg'))?param('excludeorg'):""; my $excludegov=(param('excludegov'))?param('excludegov'):""; my $excludeedu=(param('excludeedu'))?param('excludeedu'):""; my $excludecom=(param('excludecom'))?param('excludecom'):""; my $mission=(param('mission'))?param('mission'):""; my $values=(param('values'))?param('values'):""; my $vision=(param('vision'))?param('vision'):""; my $listings=(param('RadioGroup2'))?param('RadioGroup2'):"40"; my $searchengine=(param('RadioGroup3'))?param('RadioGroup3'):"www.google.com"; my $action=(param('search'))?param('search'):""; my $url=(param('url'))?param('url'):""; ########################################################## my ($srchresult,$buff,@buff,$nexts,$j,$count,$ban1,$ban2,$ban3); my ($error,$string,$m,$checked); $checked=""; $checked="checked" if ($action eq ""); $ban1=""; $ban2=""; $ban3=""; if (open(B,"banner1.tpl")) { @buff=; close(B); $ban1=join '',@buff; } if (open(B,"banner2.tpl")) { @buff=; close(B); $ban2=join '',@buff; } if (open(B,"banner3.tpl")) { @buff=; close(B); $ban3=join '',@buff; } my %selectbox = ( "aerospace OR Aviation OR Defense" => "Aerospace Aviation and Defense", "agency" => "Agency", "agricultural OR farm" => "Agriculture", "architectural" => "Architecture", "automotive" => "Automotive", "chemical OR solvent OR paint" => "Chemicals and Allied Products", "church OR religious" => "Church and Religious", "communications OR networking OR telecommunications OR LAN" => "Communications and Networking", "computer OR software OR information technology" => "Computers & Information Technology", "construction OR builder OR engineering" => "Construction and Engineering", "consumer electronics" => "Consumer Electronics", "convention OR trade show" => "Conventions and Trade Shows", "distribution OR distributor" => "Distribution", "education OR university OR high school OR grade school" => "Education", "electrical contractor OR electrician" => "Electrical Contractor", "electronic commerce OR ecommerce OR ebusiness" => "Electronic Commerce", "entertainment OR hospitality" => "Entertainment and Hospitality Industry", "environmental" => "Environment", "financial services" => "Financial Services", "floral OR florist" => "Florist", "food OR beverage OR provisioning OR bottling" => "Food and Beverage", "fundraising" => "Fundraising", "health care OR hospital OR laboratory" => "Health Care", "heating OR air conditioning OR HVAC" => "Heating and Air Conditioning", "cleaning OR maid OR home repair OR plumbing OR window OR roofing" => "Home services", "industrial supplies" => "Industrial Supplies", "catalog OR mail order" => "Mail Order and Catalog Sales", "manufacturing" => "Manufacturing", "marketing OR advertising" => "Marketing and Advertising", "news OR media" => "News and Media", "office supply OR equipment" => "Office Supplies and Equipment", "energy OR oil OR gas OR coal OR mining" => "Oil and Energy", "pharmaceutical OR drug" => "Pharmaceutical", "plumbing contractor OR plumber" => "Plumbing", "consulting OR consultancy" => "Prof Svcs - Consulting", "design firm OR design" => "Prof Svcs - Design", "training OR development" => "Prof Svcs - Training and Development", "professional services" => "Professional Services", "publishing OR printing" => "Publishing and Printing", "real estate OR realty" => "Real Estate", "research and development" => "Research and Development", "retail" => "Retail", "security OR investigative services" => "Security & Investigative Services", "shipping OR transportation OR logistic" => "Shipping & Transportation", "software consultant" => "Software Consultant", "software publisher OR software development" => "Software Developer or Publisher", "sports OR baseball OR football OR soccer OR basketball" => "Sports Team", "systems integration" => "Systems Integrator", "telecommunications OR telephone" => "Telecommunications", "travel" => "Travel", "trucking" => "Trucking", "internet OR web" => "Web and Internet", "wholesale" => "Wholesale" ); if ($url ne "" || $action ne "") { if ($url eq "" ) { if ($radio eq ""){ # EDIT HERE THE ERROR IN HTML FORMAT $error= qq|
There was an error!

There was no search criteria defined.
|; # END EDITING } else { if ($radio eq "industry" && $select eq ""){ # EDIT HERE THE ERROR IN HTML FORMAT $error= qq|
There was an error!

You selected "Search by Industry" but no industry type was selected.
|; # END EDITING } if ($radio eq "radiobutton" && $textfield eq ""){ # EDIT HERE THE ERROR IN HTML FORMAT $error= qq|
There was an error!

You selected "Search by Company Name" but no company name was given.
|; # END EDITING } if ($radio eq "keyword" && $keyword eq ""){ # EDIT HERE THE ERROR IN HTML FORMAT $error= qq|
There was an error!

You selected "Search by keyword" but no keyword was given.
|; # END EDITING } } ############################################################## if ($error) { print_page($error); exit(113); } $string=""; $string.=" $mission" if ($mission ne ""); $string.=" $values" if ($values ne ""); $string.=" $vision" if ($vision ne ""); $string.=" $excludeorg" if ($excludeorg ne ""); $string.=" $excludegov" if ($excludegov ne ""); $string.=" $excludeedu" if ($excludeedu ne ""); $string.=" $excludecom" if ($excludecom ne ""); $string.=" $select" if ($radio eq "industry"); $string.=" $textfield" if ($radio eq "radiobutton"); $string.=" $keyword" if ($radio eq "keyword"); # if ($searchengine =~ /yahoo/) { # $string="http://search.yahoo.com/search?p=".$string."&ei=UTF-8&fr=fp-tab-web-t&n=".$listings."&fl=0&x=wrt"; # } else { $string="http://www.google.com/search?num=".$listings."&hl=en&lr=&ie=UTF-8&safe=off&q=".$string."&btnG=Search"; # } } else { $string=$url; $string=~ s/\%26/\&/g; } $string=~ s/\+/\%2B/g; $string=~ s/\s/\+/g; my $body=""; my $ol=1; my $headers="";my $bodyresult=""; my $ua = LWP::UserAgent->new('agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0'); my $req_get = new HTTP::Request "GET"; $req_get->url($string); my $response = $ua->request($req_get); if ( $response->is_success) { $body = $response->content(); # content without HTTP header if ($body){ $bodyresult= qq|
We didn't find any Web pages matching the search criteria.
Suggestions:
  • Check your spelling.
  • Try more general words.
  • Try different words that mean the same thing. |; $body=~ s/\n//g; if ($searchengine =~ /yahoo/ ) { if ($body=~ /\(.*)\<\/ol\>/){ $ol=$1; $srchresult=$2; $bodyresult="
      \n"; $srchresult=~ s/yschurl/blue/g; $srchresult=~ s/\/\<\/small\>/g; $srchresult=~ s/\/\/g; $srchresult=~ s/\s+class\=yschttl//g; $srchresult=~ s/\s+class\=yschabstr//g; $srchresult=~ s/\>Cached\\Cached\<\/small\>\More pages from this site\\More pages from this site\<\/small\>\/,$srchresult); $count=0; $j=1; foreach $buff (@buff) { # exclude empty results $count++ if ($buff ne "" ); } foreach $buff (@buff) { $j++; $m=""; $bodyresult.="
    1. ".$buff."
      $m
      \n" if ($buff ne "" ); $m=$ban2 if ($j == int ($count/2) && $count >= 2); } $bodyresult.="
    \n"; if ($body =~ /
    (.*)\<\/div\>\
    /) { $nexts=$1; $nexts=~ s/\&/\%26/g; $nexts=~ s/\%26nbsp\;/\ /g; $nexts=~ s/\ 0 ) { $ol = $1+1; } } #if ($body=~ /\(.*?)\<\/div\>/){ @buff= $body =~ /\
    ]*\>.*?\<\/div\>/gmi; $bodyresult="
      \n"; $count=0; $j=0; foreach $buff (@buff) { # exclude empty results $count++ if ($buff ne ""); } foreach $srchresult (@buff) { if ($srchresult ne "") { $j++; $m=""; $srchresult=~ s/\
      ]+\>//g; $srchresult=~ s/\<\/div\>//g; $srchresult=~ s/\

      //g; $srchresult=~ s/\<\/h2\>//g; $srchresult=~ s/\/\/g; $srchresult=~ s/\/\/g; $srchresult=~ s/\<\/font\>/\<\/small\>/g; $srchresult=~ s/\/\/g; $srchresult=~ s/\s+class\=fl//g; $srchresult=~ s/\\.*?\<\/i\>\<\/span\>\//g; $srchresult=~ s/\=\/search/\=http\:\/\/www.google.com\/search/g; $srchresult=~ s/\=\"\/search/\=\"http\:\/\/www.google.com\/search/g; $srchresult=~ s/href\=\/url/href\=\http\:\/\/www.google.com\/url/g; $m=$ban2 if ($j == int ($count/2) && $count >= 2); $bodyresult.="
      $m
    1. ".$srchresult; } } if ($body=~ /\