Getting content of a website via PHP [closed]
How do I get the content of a page via PHP? How do i grab the text of a blog post because most RRS feed only give the link to the article so i cant use that. Is there a PHP function for this or anyway about doing this. Please offer some suggestions :).
To just load a page, HTML and all, you can use fopen on the web address:
$page = file_get_contents('http://www.blog.com/one-example-post');
For more advanced handling of web pages, the cURL library will interact more cleverly with the remote server (for example, if there is HTTP authentication, or it's an https page).
Once you have the contents of the page, though, you're probably going to need to do some screen scraping (aka web scraping)... and you're in luck, since I just did this for another project. Here's a great library that I uncovered to help with this down-and-dirty technique. Good luck.
cURL is an option, especially if you need your application to behave like a browser (e.g. set a USER AGENT, etc.). You can also use [file_get_contents]
(see: http://php.net/manual/en/function.file-get-contents.php) which is good enough for simple applications.
精彩评论