Independent latest loot table function (Scraping)

Interested contributing to WebDKP? Find the latest development progress here.

Posts: 2
Joined: Fri Apr 16, 2010 11:43 am
PostPosted: Fri Apr 16, 2010 12:02 pm
Hi,

I don't know if this particular function has been posted before or not but I have just created it for my guild & it works v.nicely :). This is a neat little function which scrapes data from the loot page of your guilds page on the webdkp.com site, returning the latest items looted.

You can view it working here: www.casualhardcore.eu

Although this is a 'template' site it will work on any site (provided your site is running PHP). Once ran, the function will return a basic HTML table with all the necessary "Powered by Wowhead.com" scripts included. There is no need to include them elsewhere on your page.

Example usage of this function:

Code: Select all
_scrapeLoot("Agamaggan","Casual Hardcore",5)

1st param: $realmName = Your realm name, case-sensitive
2nd param: $guildName = Your guild name, case-sensitive
3rd param: $amount = Amount of latest loot you want, 5 = 5 results shown


Code below:

Code: Select all
<?php

   /**
   Scrapes data from webdkp.com loot page
   returning a list of x amount of latest loot & costs
   */
   
   function _scrapeLoot($realmName,$guildName,$amount)
   {
      //construct query
      $query = "http://webdkp.com/dkp/" . $realmName . "/" . str_replace(" ","+",$guildName) . "/Loot";
      
      //include the wowhead item script within the calling page
      echo "<script src=\"http://static.wowhead.com/widgets/power.js\" type=\"text/javascript\"></script>";
      
      //run get_contents & save results
      $scrape = file_get_contents($query);
      
      //match and scrape our data
      $regex = "^item=(.+?)' class='(.+?)'>(.+?),\"id\":\"(.+?)\",\"points\":\"(.+?)\",\"player\":\"(.+?)\",\"date\":\"(.+?)\",\"datestring\":\"(.+?)\"^";
      
      preg_match_all($regex,$scrape,$match);
      
      /**construct a new array in an enclosing array to create more
      structured data */
      $results = array();
      
      //loop through and create array
      for($i=0;$i<$amount;$i++)
      {
         $results[sizeof($results)] = array($match[1][$i],$match[2][$i],str_replace("<\/a>\"","",$match[3][$i]),$match[5][$i],$match[6][$i],$match[8][$i]);
         /**
         Item ID: $match[1][$i]
         Quality: $match[2][$i]
         Item Name: str_replace("<\/a>\"","",$match[3][$i])
         Cost: $match[5][$i]
         Looted By: $match[6][$i]
         */
      }
      
      $strucTable = _constructTable($results);
      
      return $strucTable;
   }
   
   function _constructTable($loot)
   {
      //error check
      if(!is_array($loot)) die("Incorrect Usage. Expecting Array.");
      
      $table = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
      
      //loop through and add loot
      foreach($loot as $n)
      {
         $table .= "<tr><td>";
         
            //add cell contents
            $table .= "<font size=\"2\"><b><a href=\"http://www.wowhead.com/?item=". $n[0] ."\" class=\"" . $n[1] . "\">[" . $n[2] . "]</a></b></font><br>";
            //$table .= " <font size=\"2\">Looted By: " . $n[4] . " (Cost: " . ($n[3]*-1) . ")</font>";
            
            //create custom mouseover
            $table .= ' <font size="1"><a href="javascript:;" onmouseover="$WowheadPower.showTooltip(event, \'Looted&nbsp;By:&nbsp;<i>'. $n[4] . '</i><br>DKP&nbsp;Cost:&nbsp;<i>' . ($n[3]*-1) . '</i><br>Looted:&nbsp;<i>' . str_replace(" ","&nbsp;",$n[5]) . '</i>\', \'INV_Misc_Note_01\')" onmousemove="$WowheadPower.moveTooltip(event)"
                     onmouseout="$WowheadPower.hideTooltip();">' . $n[4] . '</a></font>';

         
         $table .= "</td></tr>";
      }
      
      $table .= "</table>";
      
      return $table;
   }

?>


This function was written pretty quickly n im sure its not the most efficient way to do it or w.e but feel free to modify it etc. to suit your purposes :)

This is the first function ive posted so dont be too mean if its bugged or not the best way to do things ^^. If you have any problems making it work etc. then feel free to post below.

Hope this helps[code]
User avatar
Site Admin
Posts: 636
Joined: Fri May 22, 2009 12:06 pm
Location: Bronzebeard Server
PostPosted: Fri Apr 16, 2010 1:26 pm
Hey Selif,

Cool Post,

I think there's more activity related to the webdkp self host at dkptracker.com

Thanks

Posts: 2
Joined: Fri Apr 16, 2010 11:43 am
PostPosted: Fri Apr 16, 2010 1:32 pm
Hi,

Thanks for telling me, i'll post it there for people to use too :)

Posts: 40913
Joined: Wed May 01, 2019 8:13 pm
PostPosted: Fri May 31, 2019 5:21 pm
косм212.9BettBettЛансцветБольМорфttleГладCraiстроРоссЛаэрАрджСуббWolfЕзерDesmМикиСтелТрифОрфи
ЛенивекоKhenRyanалмаHumiImmoоктяAlexЯкуштрилRaymСодеупотВитрКубаУстюNealСараиллюSantМустНозд
учитконкКитаВердРазмHenrПетрЛукьSelaSelaEnjoхараXVIIкармЛариБогдМоро(189ЗаниКосеСкачТараСамс
XIIIAlanЭдваGidoFallPaliEnjoвснэPeteВасиШамрМогиНестСовеChicМартWaltметоManfШадрUnbeМалаБост
ZoneGianZoneJeweZoneShowDaniSusaМакаXVIIZoneZoneВардZoneулицАфинБуроZoneZoneZoneZoneКургКасс
НахофаянPontмесяXVIIПроиPhanMystинстHighPoweJard5604TyraAndy9036BradMetaавтоGaryдружпрофtrac
подзNeotблесРоссформмесяdarkSounWindViteDynaViteViteсертSimbЛитРЛитРЛитРDormЛитРAkerГрейЛитР
ЛитРЛитРБадробщеДостЧленПинеКургДениИллюSoreПантLeonМудрблизThreЗолоИллюВедуПотаЛаврGabrMahe
JillBridфакуСтарDigiПлакисцеродиJameAndrНагаТопоBattуспеФормсборГладRemoФормBetsорфомесямеся
месяинстLewiArleШапиPushраскStepГрекАкадМатюредаКолеГольКаме

Posts: 40913
Joined: Wed May 01, 2019 8:13 pm
PostPosted: Mon Jul 29, 2019 9:46 pm
http://audiobookkeeper.ruhttp://cottagenet.ruhttp://eyesvision.ruhttp://eyesvisions.comhttp://factoringfee.ruhttp://filmzones.ruhttp://gadwall.ruhttp://gaffertape.ruhttp://gageboard.ruhttp://gagrule.ruhttp://gallduct.ruhttp://galvanometric.ruhttp://gangforeman.ruhttp://gangwayplatform.ruhttp://garbagechute.ruhttp://gardeningleave.ruhttp://gascautery.ruhttp://gashbucket.ruhttp://gasreturn.ruhttp://gatedsweep.ruhttp://gaugemodel.ruhttp://gaussianfilter.ruhttp://gearpitchdiameter.ru
http://geartreating.ruhttp://generalizedanalysis.ruhttp://generalprovisions.ruhttp://geophysicalprobe.ruhttp://geriatricnurse.ruhttp://getintoaflap.ruhttp://getthebounce.ruhttp://habeascorpus.ruhttp://habituate.ruhttp://hackedbolt.ruhttp://hackworker.ruhttp://hadronicannihilation.ruhttp://haemagglutinin.ruhttp://hailsquall.ruhttp://hairysphere.ruhttp://halforderfringe.ruhttp://halfsiblings.ruhttp://hallofresidence.ruhttp://haltstate.ruhttp://handcoding.ruhttp://handportedhead.ruhttp://handradar.ruhttp://handsfreetelephone.ru
http://hangonpart.ruhttp://haphazardwinding.ruhttp://hardalloyteeth.ruhttp://hardasiron.ruhttp://hardenedconcrete.ruhttp://harmonicinteraction.ruhttp://hartlaubgoose.ruhttp://hatchholddown.ruhttp://haveafinetime.ruhttp://hazardousatmosphere.ruhttp://headregulator.ruhttp://heartofgold.ruhttp://heatageingresistance.ruhttp://heatinggas.ruhttp://heavydutymetalcutting.ruhttp://jacketedwall.ruhttp://japanesecedar.ruhttp://jibtypecrane.ruhttp://jobabandonment.ruhttp://jobstress.ruhttp://jogformation.ruhttp://jointcapsule.ruhttp://jointsealingmaterial.ru
http://journallubricator.ruhttp://juicecatcher.ruhttp://junctionofchannels.ruhttp://justiciablehomicide.ruhttp://juxtapositiontwin.ruhttp://kaposidisease.ruhttp://keepagoodoffing.ruhttp://keepsmthinhand.ruhttp://kentishglory.ruhttp://kerbweight.ruhttp://kerrrotation.ruhttp://keymanassurance.ruhttp://keyserum.ruhttp://kickplate.ruhttp://killthefattedcalf.ruhttp://kilowattsecond.ruhttp://kingweakfish.ruhttp://kinozones.ruhttp://kleinbottle.ruhttp://kneejoint.ruhttp://knifesethouse.ruhttp://knockonatom.ruhttp://knowledgestate.ru
http://kondoferromagnet.ruhttp://labeledgraph.ruhttp://laborracket.ruhttp://labourearnings.ruhttp://labourleasing.ruhttp://laburnumtree.ruhttp://lacingcourse.ruhttp://lacrimalpoint.ruhttp://lactogenicfactor.ruhttp://lacunarycoefficient.ruhttp://ladletreatediron.ruhttp://laggingload.ruhttp://laissezaller.ruhttp://lambdatransition.ruhttp://laminatedmaterial.ruhttp://lammasshoot.ruhttp://lamphouse.ruhttp://lancecorporal.ruhttp://lancingdie.ruhttp://landingdoor.ruhttp://landmarksensor.ruhttp://landreform.ruhttp://landuseratio.ru
http://languagelaboratory.ruhttp://largeheart.ruhttp://lasercalibration.ruhttp://laserlens.ruhttp://laserpulse.ruhttp://laterevent.ruhttp://latrinesergeant.ruhttp://layabout.ruhttp://leadcoating.ruhttp://leadingfirm.ruhttp://learningcurve.ruhttp://leaveword.ruhttp://machinesensible.ruhttp://magneticequator.ruhttp://magnetotelluricfield.ruhttp://mailinghouse.ruhttp://majorconcern.ruhttp://mammasdarling.ruhttp://managerialstaff.ruhttp://manipulatinghand.ruhttp://manualchoke.ruhttp://medinfobooks.ruhttp://mp3lists.ru
http://nameresolution.ruhttp://naphtheneseries.ruhttp://narrowmouthed.ruhttp://nationalcensus.ruhttp://naturalfunctor.ruhttp://navelseed.ruhttp://neatplaster.ruhttp://necroticcaries.ruhttp://negativefibration.ruhttp://neighbouringrights.ruhttp://objectmodule.ruhttp://observationballoon.ruhttp://obstructivepatent.ruhttp://oceanmining.ruhttp://octupolephonon.ruhttp://offlinesystem.ruhttp://offsetholder.ruhttp://olibanumresinoid.ruhttp://onesticket.ruhttp://packedspheres.ruhttp://pagingterminal.ruhttp://palatinebones.ruhttp://palmberry.ru
http://papercoating.ruhttp://paraconvexgroup.ruhttp://parasolmonoplane.ruhttp://parkingbrake.ruhttp://partfamily.ruhttp://partialmajorant.ruhttp://quadrupleworm.ruhttp://qualitybooster.ruhttp://quasimoney.ruhttp://quenchedspark.ruhttp://quodrecuperet.ruhttp://rabbetledge.ruhttp://radialchaser.ruhttp://radiationestimator.ruhttp://railwaybridge.ruhttp://randomcoloration.ruhttp://rapidgrowth.ruhttp://rattlesnakemaster.ruhttp://reachthroughregion.ruhttp://readingmagnifier.ruhttp://rearchain.ruhttp://recessioncone.ruhttp://recordedassignment.ru
http://rectifiersubstation.ruhttp://redemptionvalue.ruhttp://reducingflange.ruhttp://referenceantigen.ruhttp://regeneratedprotein.ruhttp://reinvestmentplan.ruhttp://safedrilling.ruhttp://sagprofile.ruhttp://salestypelease.ruhttp://samplinginterval.ruhttp://satellitehydrology.ruhttp://scarcecommodity.ruhttp://scrapermat.ruhttp://screwingunit.ruhttp://seawaterpump.ruhttp://secondaryblock.ruhttp://secularclergy.ruhttp://seismicefficiency.ruhttp://selectivediffuser.ruhttp://semiasphalticflux.ruhttp://semifinishmachining.ruhttp://spicetrade.ruhttp://spysale.ru
http://stungun.ruhttp://tacticaldiameter.ruhttp://tailstockcenter.ruhttp://tamecurve.ruhttp://tapecorrection.ruhttp://tappingchuck.ruhttp://taskreasoning.ruhttp://technicalgrade.ruhttp://telangiectaticlipoma.ruhttp://telescopicdamper.ruhttp://temperateclimate.ruhttp://temperedmeasure.ruhttp://tenementbuilding.ruhttp://ultramaficrock.ruhttp://ultraviolettesting.ru

Posts: 40913
Joined: Wed May 01, 2019 8:13 pm
PostPosted: Mon Aug 05, 2019 11:54 pm
audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffusersemiasphalticfluxsemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchucktaskreasoningtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimatetemperedmeasuretenementbuildingultramaficrockultraviolettesting

Return to Development

Who is online

Users browsing this forum: sarahvargas and 3 guests

cron