Designer? Programmer? Enthusiast? Join Open Designs Now!

Open Designs Forum » Designer Talk

Import content from another web site/page

(8 posts)
  1. willwood
    Member

    Hi,

    This is my first post on these forums, so please go easy on me! :D

    Was wondering if there is an easy way to import a DIV or CLASS container from another website to embed in my own website. I am only looking to import a specific container from a second website, so although I could use an iFrame or object-embed, the problem is it displays the entire page which I want to avoid.

    Are we looking at PHP or JQuery to achieve this sort of thing?

    The scenario is that I am setting up a new website to publish weather data on. This weather data is being uploaded from a home weather station and is presented in a standard HTML page. There is a 'weather summary' presented in a divider at the top. It is this I want to import into my page.

    I've searched the inter-webs and not been able to find much other than using an iFrame or object-embed. I don't know if anyone could be kind enough to point me towards some relevant information or indeed offer me any suggestions or examples of how this could best be done.

    Thanks in advance,
    Will.

    Posted 2 years ago #
  2. uberlemurguy
    Moderator

    you could scrape it with PHP or jQuery, but that would be very inefficient. You would have to implement a caching thing.

    If you know PHP, look at this: http://www.jonasjohn.de/lab/htmlsql.htm

    Posted 2 years ago #
  3. Sean
    Founding Member

    Why not just go to weather.com and download the weather widget from them? They provide code to embed in your own website to show weather based on any information you provide (city, state, zip/postal code, etc).

    Posted 2 years ago #
  4. willwood
    Member

    Hi,
    Thanks for your feedback. The reason I am not using weather.com is because I am uploading my own weather data from my own weather station outside. Although I have an option to publish data to Weather Underground or similar organisations, I want to publish it on my own website without relying on a third-party.

    In the end, I decided to use PHP. I'm using a simple file_get_contents function which fetches only the required content from the HTML page created by the weather station software and presents it on my blog.

    I don't know that much about performance or site optimisation in terms of server side scripting. But the method I've arrived at seems very reliable and I am not noticing any performance related issues when the page loads.

    Posted 2 years ago #
  5. Weather.com has rss feeds by zip code for weather. just parse that and display it how you want.

    Posted 2 years ago #
  6. greg
    Member

    When using file_get_contents() it's usually a good idea to set up some sort of caching so that you're not getting the same information over and over again in a small time period. You could also take a look at curl which has better performance than file_get_contents().

    Posted 2 years ago #
  7. file get contents would require you use regex to grab the content you need. weather.com provides rss feeds which do not have cache problem becuase they are intended to keep you up to date. RSS is xml so it is very easy to parse with javascript or php.

    Posted 2 years ago #
  8. greg
    Member

    Read the OP again, he wants to use data from his own weather station.

    Posted 2 years ago #

RSS feed for this topic