3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 5.5.24 - 5.5.32, 5.5.34 - 5.6.17, 5.6.20 - 5.6.28, 7.0.0 - 7.0.3, 7.0.5 - 7.1.0
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/kJjOe on line 21 Warning: file_get_contents(http://www.teefury.com/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/kJjOe on line 21 Notice: Undefined offset: 1 in /in/kJjOe on line 32 Price: <br /> Notice: Undefined offset: 1 in /in/kJjOe on line 36 Notice: Undefined offset: 1 in /in/kJjOe on line 109 Regular Teefury! Notice: Undefined variable: i in /in/kJjOe on line 114 Notice: Undefined offset: 1 in /in/kJjOe on line 114 Notice: Undefined variable: match_shirtimg in /in/kJjOe on line 114 Shirt (): <br />
Output for 5.3.0 - 5.4.45, 5.5.33, 5.6.18 - 5.6.19, 7.0.4
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo 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 failed: System error in /in/kJjOe on line 21 Notice: Undefined offset: 1 in /in/kJjOe on line 32 Price: <br /> Notice: Undefined offset: 1 in /in/kJjOe on line 36 Notice: Undefined offset: 1 in /in/kJjOe on line 109 Regular Teefury! Notice: Undefined variable: i in /in/kJjOe on line 114 Notice: Undefined offset: 1 in /in/kJjOe on line 114 Notice: Undefined variable: match_shirtimg in /in/kJjOe on line 114 Shirt (): <br />
Output for hhvm-3.12.0
Warning: Failed to open http://www.teefury.com/ (Could not resolve host: www.teefury.com) in /in/kJjOe on line 21 Notice: Undefined index: 1 in /in/kJjOe on line 32 Price: <br /> Notice: Undefined index: 1 in /in/kJjOe on line 36 Notice: Undefined index: 1 in /in/kJjOe on line 109 Regular Teefury! Notice: Undefined variable: i in /in/kJjOe on line 114 Notice: Undefined index: 1 in /in/kJjOe on line 114 Notice: Undefined variable: match_shirtimg in /in/kJjOe on line 114 Shirt (): <br />
Output for hhvm-3.10.0

Process exited with code 137.
Output for 5.2.6 - 5.2.17
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo 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 failed: System error in /in/kJjOe on line 21 Notice: Undefined offset: 1 in /in/kJjOe on line 32 Price: <br /> Notice: Undefined offset: 1 in /in/kJjOe on line 36 Notice: Undefined offset: 1 in /in/kJjOe on line 109 Regular Teefury! Notice: Undefined variable: i in /in/kJjOe on line 114 Notice: Undefined offset: 1 in /in/kJjOe on line 114 Notice: Undefined variable: match_shirtimg in /in/kJjOe on line 114 Shirt (): <br />
Output for 5.0.4 - 5.2.5
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/kJjOe on line 21 Warning: file_get_contents(http://www.teefury.com/): failed to open stream: Connection refused in /in/kJjOe on line 21 Notice: Undefined offset: 1 in /in/kJjOe on line 32 Price: <br /> Notice: Undefined offset: 1 in /in/kJjOe on line 36 Notice: Undefined offset: 1 in /in/kJjOe on line 109 Regular Teefury! Notice: Undefined variable: i in /in/kJjOe on line 114 Notice: Undefined offset: 1 in /in/kJjOe on line 114 Notice: Undefined variable: match_shirtimg in /in/kJjOe on line 114 Shirt (): <br />
Output for 4.3.3 - 4.3.4, 4.3.10 - 4.4.9, 5.0.3
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/kJjOe on line 21 Warning: file_get_contents(http://www.teefury.com/): failed to open stream: Connection refused in /in/kJjOe on line 21 Notice: Undefined offset: 1 in /in/kJjOe on line 32 Price: <br /> Notice: Undefined offset: 1 in /in/kJjOe on line 36 Notice: Undefined offset: 1 in /in/kJjOe on line 109 Regular Teefury! Notice: Undefined variable: i in /in/kJjOe on line 114 Notice: Undefined offset: 1 in /in/kJjOe on line 114 Notice: Undefined variable: match_shirtimg in /in/kJjOe on line 114 Shirt (): <br />
Output for 4.3.5 - 4.3.9, 5.0.1 - 5.0.2
Warning: file_get_contents(): php_network_getaddresses: gethostbyname failed in /in/kJjOe on line 21 Warning: file_get_contents(http://www.teefury.com/): failed to open stream: Resource temporarily unavailable in /in/kJjOe on line 21 Notice: Undefined offset: 1 in /in/kJjOe on line 32 Price: <br /> Notice: Undefined offset: 1 in /in/kJjOe on line 36 Notice: Undefined offset: 1 in /in/kJjOe on line 109 Regular Teefury! Notice: Undefined variable: i in /in/kJjOe on line 114 Notice: Undefined offset: 1 in /in/kJjOe on line 114 Notice: Undefined variable: match_shirtimg in /in/kJjOe on line 114 Shirt (): <br />
Output for 5.0.0
Warning: file_get_contents(): php_network_getaddresses: gethostbyname failed in /in/kJjOe on line 21 Warning: file_get_contents(http://www.teefury.com/): failed to open stream: Bad file descriptor in /in/kJjOe on line 21 Notice: Undefined offset: 1 in /in/kJjOe on line 32 Price: <br /> Notice: Undefined offset: 1 in /in/kJjOe on line 36 Notice: Undefined offset: 1 in /in/kJjOe on line 109 Regular Teefury! Notice: Undefined variable: i in /in/kJjOe on line 114 Notice: Undefined offset: 1 in /in/kJjOe on line 114 Notice: Undefined variable: match_shirtimg in /in/kJjOe on line 114 Shirt (): <br />
Output for 4.3.2
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error (is your IPV6 configuration correct? If this error happens all the time, try reconfiguring PHP using --disable-ipv6 option to configure) in /in/kJjOe on line 21 Warning: file_get_contents(http://www.teefury.com/): failed to open stream: Connection refused in /in/kJjOe on line 21 Notice: Undefined offset: 1 in /in/kJjOe on line 32 Price: <br /> Notice: Undefined offset: 1 in /in/kJjOe on line 36 Notice: Undefined offset: 1 in /in/kJjOe on line 109 Regular Teefury! Notice: Undefined variable: i in /in/kJjOe on line 114 Notice: Undefined offset: 1 in /in/kJjOe on line 114 Notice: Undefined variable: match_shirtimg in /in/kJjOe on line 114 Shirt (): <br />
Output for 4.3.0 - 4.3.1
Warning: file_get_contents() [http://www.php.net/function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: System error in /in/kJjOe on line 21 Warning: file_get_contents(http://www.teefury.com/) [http://www.php.net/function.file-get-contents]: failed to create stream: Connection refused in /in/kJjOe on line 21 Notice: Undefined offset: 1 in /in/kJjOe on line 32 Price: <br /> Notice: Undefined offset: 1 in /in/kJjOe on line 36 Notice: Undefined offset: 1 in /in/kJjOe on line 109 Regular Teefury! Notice: Undefined variable: i in /in/kJjOe on line 114 Notice: Undefined offset: 1 in /in/kJjOe on line 114 Notice: Undefined variable: match_shirtimg in /in/kJjOe on line 114 Shirt (): <br />