TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   help with curl (http://www.talkphp.com/general/3210-help-curl.html)

sarmenhb 08-03-2008 10:22 PM

help with curl
 
im trying to figure out how to parse email addresses from a webpage
this is how far i got.

Code:

<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://www.google.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ;
$data = curl_exec($ch);
curl_close($ch);

?>

the variable $data holds the html source code and i tryed using preg_match to look for the email and print it out.
can someone show me a sample code on how to do this

thanks

delayedinsanity 08-03-2008 11:32 PM

Quote:

im trying to figure out how to parse email addresses from a webpage
Well, first of all you need to.... HOLD UP. If I get any spam from any script you're about to write, I will cURL your address and egg your house, I promise.
-m

sarmenhb 08-04-2008 03:31 AM

well, im not directly trying to make a email parser. im trying to figure out how to parse certain things.

for example if i wanted to parse out all the keywords that were used on a certain page. how do i display those out nicely on the screen.

xenon 08-04-2008 06:19 PM

well...you parse the content :-D Use regex if nothing else is available. What are we supposed to tell you?

PHP Code:

preg_match('/\b(.*?@.*?\.[a-z\.]{2,6})\b/si'$data$matches); 

This is the most basic regex you could use, I think.

PS: why did you open 2 threads for this?

sarmenhb 08-05-2008 02:32 AM

no one was responding.

so basically the variable holds the html and i can use a loop to loop through it and output what i need right?

xenon 08-05-2008 08:42 PM

Yes, you got it :-)


All times are GMT. The time now is 04:29 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0