PHP file_get_contents [英] PHP file_get_contents

查看:83
本文介绍了PHP file_get_contents的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个PHP脚本,其中,用户将提供一个网页链接,它将获取该网页的内容,并根据其内容解析内容.

I'm looking to create a PHP script where, a user will provide a link to a webpage, and it will get the contents of that webpage and based on it's contents, parse the contents.

例如,如果用户提供了YouTube链接:

For example, if a user provides a YouTube link:

http://www.youtube.com/watch?v=xxxxxxxxxxx

然后,它将获取有关该视频的基本信息(缩略图,嵌入代码?)

Then, it will grab the basic information about that video (thumbnail, embed code?)

或者他们可能会提供一个vimeo链接:

Or they might provide a vimeo link:

 http://www.vimeo.com/xxxxxx

或者即使他们提供任何链接,但都没有附加视频,例如:

Or even if they were to provide any link, without a video attached, such as:

 http://www.google.com/

它可以仅获取页面标题或一些元内容.

And it could grab just the page Title or some meta content.

我想我必须使用file_get_contents,但是我不确定在这种情况下如何使用它.

I'm thinking I'd have to use file_get_contents, but I'm not exactly sure how to use it in this context.

我不是要找人来编写整个代码,而是可能为我提供一些工具,以便我可以完成此工作.

I'm not looking for someone to write the entire code, but perhaps provide me with some tools so that I can accomplish this.

推荐答案

您可以使用 http 库.您发送http请求,并可以使用该库从http响应中获取信息.

You can use either the curl or the http library. You send a http request, and can use the library to get the information from the http response.

这篇关于PHP file_get_contents的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆