【问题标题】:How i can get Html source code from url and put in mysql with php? [closed]我如何从 url 获取 Html 源代码并使用 php 放入 mysql? [关闭]
【发布时间】:2016-05-17 02:09:59
【问题描述】:

我在 mysql 中有一个表,其中包含一个 url 列表和一个名为 html_code 的空字段。

url|html_code

例如。网址http://www.website.com/article1.html

我需要从 url 获取源 html 代码并将其放在我的空白字段中

有可能吗? (使用php?)

【问题讨论】:

    标签: php mysql curl wget


    【解决方案1】:

    您可以使用file_get_contents(url),它将为您下载页面并设置string

    $html = file_get_contents(url);
    

    然后你可以将 html 插入到你的 mysql 数据库中

    参考:http://php.net/manual/en/function.file-get-contents.php

    注意:确保您的 PHP 配置允许您远程下载:allow_url_fopen

    参考:http://php.net/manual/en/filesystem.configuration.php

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-25
      • 2011-07-14
      • 2015-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多