There is no best way. It all depends on how interconnected these sites are and how much you "trust" them.
Using iframe
s
The use of iframe
s, as I described in this other answer, is perfectly valid when you want to insert content that is independent of the current page, either for aesthetic issues, performance or safety.
The problem of using a iframe
it is not so much that it is bad in itself, but it brings several other challenges:
- How to scale the frames and maintain a layout consistent with the rest of the page?
- What to do with links inside the frame?
- Is it necessary to interact with frame content? In this case it would be necessary to define access header from different sources.
If the content of this Wordpress site that you want to include is something that occasionally could cause security problems, such as injection scripts on your page, the iframe
helps isolate that content.
Also, if the content varies frequently and you can not build a parser, the iframe
ends up being the safest alternative.
Getting the content on the server
Using the HTML directly
If, on the other hand, you trust that other site, perhaps because you are the administrator yourself, you can do as Ricardo suggested in the other reply.
Your server makes a request to the other site and retrieves the content from the page you want to insert. Then inserts this content into your page.
In addition to safety, this technique needs to consider:
- Styles and the structure of the other page. They may not work if there are relative paths or they may interfere with the styles and structure of your page.
- Making requests to another server each time you show a page will kill your performance. Ideally, keep this information on cache, maybe in a database for a while and update from time to time.
Interpreting the information
If the content always follows the same structure, the most advanced and flexible technique is to make some code to read the content of the other site and extract only the relevant information from each product.
With this information on your server, you can handle it yourself to prevent it from bringing security risk, such as coding it into HTML by writing to the page, limiting the size, etc. Then you can display it in any format you want.
The second part of Ricardo’s answer shows this alternative, using a parser xml. But consider that HTML does not follow the same XML rules, so chances are that you will need to use some specific library to interpret HTML.
Of course, the ideal would be to be able to recover the data via web services in a friendly format like JSON, but parsing HTML breaks a branch when it is not possible.
If you are the administrator of the Wordpress site, consider that there are some plugins to work with REST. If the site uses a plugin to manage products, it is likely that it has some API. Look closely at the documentation before you draw conclusions.
Finally, to reinforce, this technique does not work well if the information read does not have a defined structure.
Your "integrate" is literally making your content appear on another site?
– William Aparecido Brandino
I will need to integrate content that will be on a page from an external site to my site.
– Wendell
Here at this link speaks well what you should do. Uses of iframe nowadays (See the answer given as certain)
– William Aparecido Brandino
But it would be the best solution?
– Wendell
That other site doesn’t have a Webservice?
– Intruso
@Intruder, the other site does not have. What I know is that it is in Wordpress.
– Wendell