Modernvox Posted October 26, 2009 Share Posted October 26, 2009 I have the following links i would like to open either all at once or one-by-one. How would i proceed? <a href="/spo/1437571200.html" target="_BLANK">/spo/1437571200.html</a> <a href="/for/1437570154.html" target="_BLANK">/for/1437570154.html</a> <a href="/mcy/1437569678.html" target="_BLANK">/mcy/1437569678.html</a> <a href="/cto/1437569423.html" target="_BLANK">/cto/1437569423.html</a> I see that the numbers start from largest to smallest. Is this something i could use to open in order? Link to comment https://forums.phpfreaks.com/topic/179000-open-link-with-largest-int-string-first/ Share on other sites More sharing options...
trq Posted October 26, 2009 Share Posted October 26, 2009 Firstly, where are these links coming from? Secondly, when you say open, what exactly do you mean? You want to make http requests for these pages? Why? They are on your site, there must be a better way. Link to comment https://forums.phpfreaks.com/topic/179000-open-link-with-largest-int-string-first/#findComment-944385 Share on other sites More sharing options...
Modernvox Posted October 26, 2009 Author Share Posted October 26, 2009 Firstly, where are these links coming from? Secondly, when you say open, what exactly do you mean? You want to make http requests for these pages? Why? They are on your site, there must be a better way. Hi thorpe. These links are actually on CL. I would like to carry out an auto-process where i search for an item i.e, video games. Grab the results, click on each link to see if there is an email address provided. If so, copy to DB. Currently i have the script working to list all the results for my keyword search, but how do i open each link from the list to check for the email address? Do I open one at a time? Do i use preg_match_all for the email? My current code id as follows <?php function curlURL($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2'); $output = curl_exec($curl); return $output; } $curlResults = curlURL("http://southcoast.craigslist.org/sss/"); $pattern = '#<a href="(/[a-z]{3}/\d{10}\.html)">#'; preg_match_all( $pattern, $curlResults, $matches); echo "<pre>\n"; echo "Links:\n\n"; foreach ($matches[1] as $link): echo "\t" . '<a href="' . $link . '" target="_BLANK">' . $link . '</a>' . "\n"; endforeach; echo '</pre>'; ?> Link to comment https://forums.phpfreaks.com/topic/179000-open-link-with-largest-int-string-first/#findComment-944388 Share on other sites More sharing options...
trq Posted October 26, 2009 Share Posted October 26, 2009 These links are actually on CL. Cool, I've no idea what that means. Do I open one at a time? Do i use preg_match_all for the email? You can't open more than one at a time so yes. And yes, preg_match is great for matching email's within strings. Link to comment https://forums.phpfreaks.com/topic/179000-open-link-with-largest-int-string-first/#findComment-944403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.