History
User page Edit Discussion

User:Darkstar

From Woot Wiki

Jump to: navigation, search

Creator of Darkstar's Woot-off checker, a web based woot!-off checker, and DSWoot, a software based woot!-off checker.

Contents

[edit] Overview

A web interface that allows users to stay informed about items on sale at woot.com. The checker has 2 functions; it allows users to stay on one website and not have to even refresh it to stay up-to-date, and it caches the results it fetches from woot.com. What does this mean? Simple! If one person hits the checker in a 90 second period during non-woot-off times (or 15 seconds during a woot-off) the checker fetches from woot once and stores the results. If 10,000 people hit the checker in the same amount of time, it STILL only fetches from woot ONCE! This saves woot a significant amount of bandwidth due to the fact that there are dozens of people hosting this and other similar caching scripts.
The checker works on-demand, which is to say it only fetches from woot when 2 conditions are met:
  • 1: The checker is accessed via the web interface
  • 2: The cache is either nonexistent or its age is greater than $refresh (a variable defined in xmlparse.php).
The cache is timestamped to allow for its age to be calculated so it doesn't refresh more often than $refresh.

[edit] Why?

I wanted to help the woot community in some way so I decided to host a woot-checker script. I didn't like the way some looked and I was unable to decipher others (and was unwilling to host anything I didn't understand)...that and my ego kicked in and I figured I could do it myself, and better.

[edit] Progression

There have been a lot of versions. Have fun reading about them all! Hopefully you have as much fun understanding the evolutions as I had writing them.

[edit] Version 1 Beta

First came a beta and it didn't do a heck of a lot. It used fopen() to fetch the woot page and saved it ran a few regular expressions to scrape the required information from the woot index page. This version was for personal use only.

[edit] Version 1.0

Next 1.0 came into existence and used lynx to fetch the data from woot. The html was parsed the same way and had a meta refresh to allow your index finger to rest from mashing that F5 button. The meta refresh used an if to allow it to adapt based on whether a woot-off was in progress and what percent was left.

[edit] Version 1.0c

1.0c was the next version to come into play (the c stands for curl). It used curl to fetch from woot which was more reliable than lynx and allowed for a script timeout to avoid hanging.

[edit] Versions 1.1 and 1.1c

1.1 and 1.1c were next. 1.1 and 1.1c used AJAX to insert the content fetched from woot. This lowered bandwidth usage on the server because the homepage was only loaded once and from then on the content was inserted as needed, lowering overhead. A text-only version was included in the source for those who didn't require an image.

[edit] Woot steps in

Somewhere along the line woot released their RSS feed to lower their overhead. This actually made things easier because each important piece of information in the XML was accessible through the DOM (Data Object Model) instead of using regular expressions to search between line breaks, list items, bold tags, etc. in the HTML.

[edit] Versions 2.0 and 2.0c

2.0 and 2.0c were born to parse the XML. This was done with help from Vrillusions who wrote the original XML parsing function currently used in the checker. These versions parsed the RSS feed and stripped parts that weren't vital. The AJAX script was also rewritten to accommodate the XML. 1.1 and 1.1c made a comeback here. If 2.0 or 2.0c failed to fetch the RSS feed for any reason it would fall back to 1.1 or 1.1c depending on which version you had. This allowed the script to be more stable overall. This time 1.0 came into play. Using the original meta-refresh but still fetching from the RSS feed with a fallback to the index means the pages were mobile-friendly while still having all the features of the script. The mobile-friendly pages also allowed a user to choose whether or not to have the image displayed. The new item sound was also implemented at this time. (Wow! That was a lot of changes, no wonder it jumped from 1.1 to 2.0)

[edit] Woot makes more changes

Woot then made a few changes. The first was a request that scripts use the RSS feed as the default method of fetching information instead of scraping the homepage for data. This prompted me to make 1.1 and 1.1c unavailable for download. The second was a throttle to reduce the amount of scripts that hit the RSS feed more than they want. Some scripts were hitting the feed a few times every second (the feed updates every 30 seconds so more than every 15 seconds is ridiculous).

[edit] Version 2.1c

The throttle brought a bug to my attention. Apparently there were runaway fetches that were causing versions 2.0 and 2.0c to be throttled by woot even though the cache was set to refresh every 15 seconds during a woot-off. This caused me to rewrite a few sections of code to make the script more efficient. The image fetch was also improved since sometimes image fetching would fail and the script was set to not fetch the image unless it was a new item. The script now checks the filesize of the image to see if it failed to fetch, if so it tries again on the next RSS fetch. These fixes were packaged into version 2.1c. I chose to drop the non-curl version since it was too much to keep track of.

[edit] Version 2.2c

There was another bug that surfaced after 2.1c's release. The cache fetch was fixed which reduced the amount of calls to woot, however cache refresh was allowing all users that queried the website at the exact second of the refresh to cause it to query woot. This caused the Dear Jerkface error to still surface. I modified the conditions under which the cache can be updated and went a whole Woot!-off without incident (March 27, 2008). A new file has been added to the rar so that if a person using an iPhone or iPod Touch adds the tracker to their home screen (springboard) as a bookmark, it uses the woot exclamation point as the icon instead of a screenshot of the page. This file is called apple-touch-icon.png

[edit] Files in the .rar

Below is a detailed list of each file in the compressed source in alphabetical order and what it does.

[edit] apple-touch-icon.png

A neat little icon created by Woot! that modifies the default behavior of Apple iPod Touch and iPhone to use this icon instead of a screenshot as the home screen (springboard) icon if the checker is bookmarked to the homescreen (springboard). The Apple iPod Touch and iPhone use an icon defined in the HTML for this purpose. If it's not defined in the HTML it looks for a file called apple-touch-icon.png in the document root. If that file doesn't exist, it uses a screenshot of the web page as the icon.

[edit] fallback.php

This file was first introduced with the creation of 2.0 and 2.0c. It allows the script to attempt a secondary method of downloading the information from woot. It calls wootcache.php displays the result as an XML document that's ready to be used by the AJAX functions. It simulates a successful RSS fetch and parse.

[edit] favicon.ico

The pretty yellow icon we've all come to know and love.

[edit] index.php

The default file called when you access the web interface. It's mainly a framework for the XML to be inserted into via AJAX. It calls xmlparse.php to initiate the fetch of XML data from woot or display of cached data. It also looks pretty.

[edit] noajax.php

This page is the meta-refresh version of the full AJAX page which displays the image (index.php). This made it mobile-friendly.

[edit] noajaxtext.php

The meta-refresh version of the text-only AJAX page that does not display an image (textonly.php). Again, because of the meta-refresh it's mobile friendly.

[edit] style.css

The Cascading StyleSheet that makes all the pages look pretty.

[edit] textonly.php

The AJAX page that calls xmlparse.php to initiate the data fetching process just like index.php but without an image.

[edit] wootcache.php

This is the script called by fallback.php. It's the original method of extracting the item information from woot's site. It uses curl to download the source of the index page and saves it as rawwoot.txt. It then proceeds to use regular expressions via preg_match() to find particular sections that contain the required information. It saves the information in a text file called wootcache.txt.

[edit] xmlajax.js

This nifty little Javascript file is particularly important since it's what ties everything together. It fetches the output of xmlparse.php (or fallback.php if xmlparse fails). It writes the output to the appropriate portions of the HTML without having to refresh anything manually.

[edit] xmlparse.php

This is the most important part of the whole package. This is what actually fetches the data and image. If the cache is out of date or nonexistent it fetches the RSS feed and saves it as rawwoot.xml. If it fails it calls fallback.php (see above for an explanation). If it succeeds it parses the XML and saves the vital information into a variable and also writes it to woot.xml. The data in the variable is then used as the output of the script which is used by xmlajax.js. If the cache is up-to-date it opens the cache and outputs it to be used by xmlajax.js.

[edit] Files created by the script

Below is an alphabetical list of files created by the script.

[edit] image.jpg

This is the item currently on sale. It's used in index.php and noajax.php.

[edit] rawwoot.txt

The file created by wootcache.php that contains the full HTML source of the woot index.

[edit] rawwoot.xml

The file created by xmlparse.php that contains the full woot RSS feed.

[edit] woot.xml

The file created by xmlparse.php that contains the XML cache.

[edit] wootcache.txt

The file created by wootcache.php that contains the cache saved as PHP variables.

[edit] xmlwootupdate.txt

This file is created by xmlparse.php and wootcache.php. It contains the timestamp of when the cache was updated.
Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Doctor Who
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Mystery Science Theater 3000
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Darkstar"
 
 
Hi!

I thought you'd like this page from Wikia!

http://woot.wikia.com

Come check it out!
Send confirmation


.