$str = file_get_contents($url);
preg_match_all( '/.../' , $str , $ar );
insert into tb (content) values ('$ar[1]');

解决方案 »

  1.   

    一楼的不是已经给出代码了么
    $str = file_get_contents($url);//打开你要抓取信息的页面
    preg_match_all( '/.../' , $str , $ar );//利用正则匹配你要抓取的有用信息
    insert into tb (content) values ('$ar[1]');//插入数据库~~~
      

  2.   

    我用的是php 4.4.2 ,apache 2.55 使用file_get_contents($url)。c++2005报告异常。
    版本问题???
      

  3.   

    file_get_contents -- 将整个文件读入一个字符串
    说明
    string file_get_contents ( string filename [, bool use_include_path [, resource context [, int offset [, int maxlen]]]] )
    和 file() 一样,只除了 file_get_contents() 把文件读入一个字符串。将在参数 offset 所指定的位置开始读取长度为 maxlen 的内容。如果失败,file_get_contents() 将返回 FALSE。 file_get_contents() 函数是用来将文件的内容读入到一个字符串中的首选方法。如果操作系统支持还会使用内存映射技术来增强性能。 注: 如果要打开有特殊字符的 URL (比如说有空格),就需要使用 urlencode() 进行 URL 编码。 注: context 参数可以用 NULL 来忽略。 
    preg_match -- 进行正则表达式匹配
    说明
    int preg_match ( string pattern, string subject [, array matches [, int flags]] )insert into tb (content) values ('$ar[1]');
    把你收到的数据 丢到数据库里面的sql语言,如果你什么都不会那就一个一个慢慢学
      

  4.   

    你试试
    $handle = fopen("http://www.example.com/", "r");//fopen
    $contents = fread($handle, filesize ($filename));
    fclose($handle); 
    再分析你得到的文件
    上面的(PHP 3, PHP 4, PHP 5)都可用
      

  5.   

    file_get_contents  is available in PHP 5.
    if you use PHP4,use the codes above.
      

  6.   

    用 file_get_contents 和 fsockopen哪个会好点呢?我读的是几十个页面~`
      

  7.   

    I recommended to use file_get_contents().
      

  8.   

    handle = fopen("http://www.example.com/", "r");//fopen
    我用的是php4.4.2 apache 2.55上面的语句让apache死了。
    其他用4。4。2的朋友有这个问题吗
    5。1。4正常。