3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Needs: - Shirt sizes Would it be easier to use the mobile version? http://m.teefury.com/ Also, use http://codepad.viper-7.com to check to see how the code is scraping */ /** * filename teefury.php * * This does a basic scraping of the desktop version of the Teefury homepage. Obtains the * prices, names, colors, etc., and is used for putting that data into XML. * * @author Katie Pham <kaytee.pham@gmail.com> */ // Required to print out XML header('Content-Type: application/xml'); $output = file_get_contents('http://www.teefury.com/'); $regex_title = '#"og:title" content="(.+?)"#'; $regex_shirtimg = '#og:image" content="(.+?)"#'; $regex_price = '/<span class="price">(.+?)<\/span>/s'; $twofury = FALSE; $nodisplay = 'style="display: none;"'; preg_match($regex_title, $output, $match_title); preg_match($regex_price, $output, $match_price); echo 'Price: ' . $match_price[1] . '<br />'; //var_dump($match); // Let's go here if it's Twofury if ($match_title[1] == 'The Limited Edition Cheap T-Shirt, Gone in 24hours!') { $twofury = TRUE; // Shirt images preg_match_all($regex_shirtimg, $output, $match_shirtimg); // Shirt names and authors $regex_names = '#<span class="shirt_title">(.+?)</span>#'; preg_match_all($regex_names, $output, $match_names); $regex_author_left = '#<span class="by_link_left">by <a href="(.+?)">(.+?)</a></span>#'; $regex_author_right = '#<span class="by_link_right">by <a href="(.+?)">(.+?)</a></span>#'; preg_match($regex_author_left, $output, $match_author_left); preg_match($regex_author_right, $output, $match_author_right); // Note--1st element = URL echo 'Left author: ' . $match_author_left[2] . '<br />'; echo 'Right author: ' . $match_author_right[2] . '<br />'; // Leader $regex_leader = '#class=\"current_leader_(.+?)\"(.+?)#'; $leader_image = "/images/current_leader.png"; preg_match_all($regex_leader, $output, $match_leader); $current_leader = "Leader: None"; if ($match_leader[2][0] == ' ' || $match_leader[2][1] == '/') { $current_leader = "Leader: Right"; } else if ($match_leader[2][1] == ' ' || $match_leader[2][0] == '/') { $current_leader = "Leader: Left"; } echo $current_leader . '<br />'; // Colors // Men's $regex_colors_left_men = '#<span class="qtip mens-color-box" id="(.+?)" data-hex="\#(.+?)" rel="(.+?)" style="background-color: (.+?); " title="(.+?)" data-color-name="(.+?)" data-identifier="a">#'; preg_match_all($regex_colors_left_men, $output, $match_colors_left_men); $regex_colors_right_men = '#<span class="qtip mens-color-box" id="(.+?)" data-hex="\#(.+?)" rel="(.+?)" style="background-color: (.+?); " title="(.+?)" data-color-name="(.+?)" data-identifier="b">#'; preg_match_all($regex_colors_right_men, $output, $match_colors_right_men); // Women's $regex_colors_left_women = '#<span class="qtip womens-color-box" id="(.+?)" data-hex="\#(.+?)" rel="(.+?)" style="background-color: (.+?); " title="(.+?)" data-color-name="(.+?)" data-identifier="a">#'; preg_match_all($regex_colors_left_women, $output, $match_colors_left_women); $regex_colors_right_women = '#<span class="qtip womens-color-box" id="(.+?)" data-hex="\#(.+?)" rel="(.+?)" style="background-color: (.+?); " title="(.+?)" data-color-name="(.+?)" data-identifier="b">#'; preg_match_all($regex_colors_right_women, $output, $match_colors_right_women); // Display shirt names, shirt images, and prices for($i = 0; $i < count($match_shirtimg[1]); $i++) { echo 'Shirt ' . $i . ' (' . $match_names[1][$i] . '): ' . $match_shirtimg[1][$i] . '<br />'; // Left shirt's info if ($i == 0) { for ($j = 0; $j < count($match_colors_left_men[4]); $j++) { echo 'Colors for men\'s: ' . $match_colors_left_men[4][$j] . ' (' . $match_colors_left_men[6][$j] . ')<br />'; } for ($j = 0; $j < count($match_colors_left_women[4]); $j++) { echo 'Colors for women\'s: ' . $match_colors_left_women[4][$j] . ' (' . $match_colors_left_women[6][$j] . ')<br />'; } } else { for ($j = 0; $j < count($match_colors_right_men[4]); $j++) { echo 'Colors for men\'s: ' . $match_colors_right_men[4][$j] . ' (' . $match_colors_right_men[6][$j] . ')<br />'; } for ($j = 0; $j < count($match_colors_right_women[4]); $j++) { echo 'Colors for women\'s: ' . $match_colors_right_women[4][$j] . ' (' . $match_colors_right_women[6][$j] . ')<br />'; } } } } // Nope, just a plain old day // Needs to be worked on! // Also needs: // - Author // - Shirt colors // - Price // - Sizes else { echo $match_title[1] . 'Regular Teefury!'; $regex_name = '#<span id=\'p-title\'>(.+?)<\/span>#'; preg_match($regex_name, $output, $match_name); preg_match($regex_shirtimg, $output, $match_shirt); echo 'Shirt ' . $i . ' (' . $match_name[1] . '): ' . $match_shirtimg[1] . '<br />'; } ?>
Output for git.master_jit, git.master
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for www.teefury.com failed: System error in /in/kJjOe on line 21 Warning: file_get_contents(http://www.teefury.com/): Failed to open stream: php_network_getaddresses: getaddrinfo for www.teefury.com failed: System error in /in/kJjOe on line 21 Warning: Undefined array key 1 in /in/kJjOe on line 32 Price: <br /> Warning: Undefined array key 1 in /in/kJjOe on line 36 Warning: Undefined array key 1 in /in/kJjOe on line 109 Regular Teefury! Warning: Undefined variable $i in /in/kJjOe on line 114 Warning: Undefined array key 1 in /in/kJjOe on line 114 Warning: Undefined variable $match_shirtimg in /in/kJjOe on line 114 Warning: Trying to access array offset on value of type null in /in/kJjOe on line 114 Shirt (): <br />
Output for rfc.property-hooks
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for www.teefury.com failed: System error in /in/kJjOe on line 21 Warning: file_get_contents(http://www.teefury.com/): Failed to open stream: php_network_getaddresses: getaddrinfo for www.teefury.com failed: System error in /in/kJjOe on line 21 Warning: Undefined array key 1 in /in/kJjOe on line 32 Price: <br /> Warning: Undefined array key 1 in /in/kJjOe on line 36 Warning: Undefined array key 1 in /in/kJjOe on line 109 Regular Teefury! Warning: Undefined variable $i in /in/kJjOe on line 114 Warning: Undefined array key 1 in /in/kJjOe on line 114 Warning: Undefined variable $match_shirtimg in /in/kJjOe on line 114 Warning: Trying to access array offset on null in /in/kJjOe on line 114 Shirt (): <br />

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.52 ms | 402 KiB | 8 Q