We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

Tamedo on 11/23/07


Tagged

curl scrape


Versions (?)


Scrape with curl


Published in: PHP 


  1. <?php
  2. $url="http://www.site.com";
  3. $ch = curl_init();
  4. curl_setopt($ch, CURLOPT_URL, $url);
  5. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  6. $data = curl_exec ($ch);
  7. curl_close ($ch);
  8. $regex = '/([^`]*?)/';
  9. preg_match($regex,$data,$match);
  10. echo $match[1];
  11. ?>

Report this snippet 

You need to login to post a comment.