dousenjue3214 2012-10-06 22:20
浏览 38

如何为我的自定义PHP搜索引擎索引页面到MySQL [关闭]

I have a simple PHP script that searches a MySQL database table for the requested keywords. However I am trying to make a PHP script that given a URL will import that page and grab everything inside the "content" ID. Is this possible? If it isn't I am willing to use JavaScript/jQuery.

Thanks in advance :)

Let me know if you need anymore clarification.

  • 写回答

2条回答 默认 最新

  • dsdtumf776629385 2012-10-06 22:34
    关注

    Yes this is possible, i would suggest maybe using cURL.

    You can then input a URL in and it will grab the page.

    <?php
    
    $ch = curl_init('http://finance.google.com/finance');
    
    curl_setopt($ch,CURLOPT_HEADER,0); 
    
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); // Give us the page source
    
    $cr = curl_exec($ch);
    
    preg_match_all('/href="()"/i',$cr,$pm,PREG_SET_ORDER);
    
    print_r($pm);
    
    foreach($pm as $pv) echo $pv[1] . "
    ";
    
    ?>
    

    You are going to want to edit that preg match to make sure that you get only what you want, you can then split it out and insert into a database.

    Please be aware that this is not very bandwidth efficient.

    评论

报告相同问题?

悬赏问题

  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害