Talk Blogging - Blog Community Forum

Talk Blogging

Premium Blog Forum

CURL & Regex Help Needed

This is a discussion on CURL & Regex Help Needed within the General Blogging Chat forums, part of the News and Announcements category; Hey I'm trying to do a little scraper type thing but need a bit of help.. This is my ...






Go Back   Talk Blogging - Blog Community Forum > News and Announcements > General Blogging Chat

Members List Mark Forums Read
  #1  
Old 24th-July-2008, 09:01 PM
I Love Blogging
 
Join Date: May 2007
Posts: 81,640
Default CURL & Regex Help Needed




Hey

I'm trying to do a little scraper type thing but need a bit of help..

This is my code...

php Code:
function tinyurl($url)
{
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://tinyurl.com/create.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"url=" . $url . "");
curl_setopt($ch, CURLOPT_HEADER, 0);

$result = curl_exec($ch);
preg_match('/
(.*?)
/'
, $result, $matches);
echo '';
print_r($matches);
curl_close($ch);
}

The problem I have is when I use...

php Code:
tinyurl($url);

The actual tinyurl page gets returned, I know thats the $result = curl_exec($ch); line but $result isn't even being echoed so how can I stop that?

Secondly, the regex doesn't work. That's part of the code on the page and within that I want to grab the URL but I can't seem to get it working.

Could someone kindly help me fix these errors please, thanks


Reply With Quote

Google Chrome | Articles | Baton Rouge
Powered by vBulletin® Version 3.7.2
SEO Forum | Domain Forum | Verizon Ringtones

1 2 3 4 5 6 7 8 9 10 11