How to display content of one site in another using PHP?

百般思念 提交于 2019-11-28 08:50:05

问题


I'm trying to show contents of two websites in one another , someone suggest me to use RSS reader but my question is :

is there anything else i could try to show the contents , beside using rss !?

i thought i can connect to the database of another website , but that didnt work /

thanks in advance


回答1:


some of web hosting has disabled "readfile" function. But you can use "file_get_contents" function.

$home = file_get_contents('example.com');
echo $home;



回答2:


Any PHP function that can fetch remote URLs can help you with that. This can be as simple as doing

readfile('http://example.com'); // outputs contents of URL

If you need to scrape only some contents of a URL or want to postprocess the content, consider using DOM. In case you are trying to parse a specific XML format like RSS, use a parser specialized for that format. If there is no parser for that format, use XSLT to transform it to HTML.

As for database access, why not ask the owner of the remote site and database if and how you may access it.

Like the comments below your question already suggested, if you can be more specific about the problem, we can be more specific about a solution.



来源:https://stackoverflow.com/questions/2735534/how-to-display-content-of-one-site-in-another-using-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!