Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Link Some Details From One HTML Page To Another?
Old 12-20-2007, 10:57 PM Link Some Details From One HTML Page To Another?
Average Talker

Posts: 24
Trades: 0
I am having trouble with the following site here and the weather image at the bottom not being to the correct size. The image is hotlinked from another site for which I have permission to do! The image is automatically generated by scripts on that sites server every 5 minutes with new weather information.

As my image has to always be a certain size and I suspect the original image located on the other website changes it's size as the weather updates, I clearly have a problem with pixel ratio's and an often unclear/unreadable image...

Thus, I would much rather scrap using the image and simply have the raw-text in this image on my site. If you look at the source code for the site here, there is this piece of code:

Code:
<font face="Arial"><center><TABLE BORDER=1 CELLPADDING=5 CELLSPACING=1 BGCOLOR="FFFFFF">
<TR><TH colspan=4><B><FONT SIZE=+2 color="#0000FF">Weather Data</FONT></B></TH></TR>
<TR><TH colspan=4><B><FONT SIZE=+1 color="#5">LAST READING AT TIME: 3:40 AM  DATE: 21 December 2007 ,Time of next update: 03:45 AM</FONT></B></TH></TR>
<tr><td><FONT SIZE=+1>Current Weather<FONT SIZE=+0></td><td>Night time\Dry</FONT></td>
<td><font color="#009900"><FONT SIZE=+1>Current Temperature </td><td><font color="#009900"><b>3.8&deg;C (38.8&deg;F)</b>,  Apparent temp 2.7 &deg;C</FONT></font></td></tr>
<tr><td><FONT SIZE=+1><FONT COLOR="#FF0000">Maximum Temperature </FONT><FONT SIZE=+0> (since midnight)</td><td><FONT COLOR="#FF0000">4.0 &deg;C at: 12:00 AM</font></FONT></td>
<td><FONT SIZE=+1><FONT COLOR="#3333FF">Minimum Temperature </FONT><FONT SIZE=+0> (since midnight)</td><td><FONT COLOR="#3333FF">3.2 &deg;C at: 12:48 AM</font></FONT></td>
<tr><td><FONT SIZE=+1>Average windspeed<FONT SIZE=+0> (ten minute)</td><td>0.0 kts (0.0 kmh)</FONT></td>
<td><FONT SIZE=+1>Wind Direction<FONT SIZE=+0> (ten minute)</td><td>ENE (70&deg;)</FONT></tr></td>
<tr><td><FONT SIZE=+1>Windchill Temperature </td><td>3.8&deg;C</FONT></td>
<td><FONT SIZE=+1><font color="#009900">Maximum Gust </font><FONT SIZE=+0> (last hour)</td><td><font color="#009900">0.0 kts (0.0 kmh) at: 3:00 AM</font></FONT></td></tr>
<tr><td><FONT SIZE=+1><font color="#009900">Maximum Gust </font><FONT SIZE=+0> (since midnight)</td><td><font color="#009900">0.0 kts (0.0 kmh) at: 1:52 PM</font></FONT></td>
<td><FONT SIZE=+1>Maximum 1 minute average <FONT SIZE=+0> (since midnight)</td><td>0.0 kts (0.0 kmh) at: 1:57 PM</FONT></td></tr>
<tr><td><FONT SIZE=+1>Rainfall <FONT SIZE=+0> (last hour)</td><td>0.00 in. (0.0 mm)</FONT></td>
<td><FONT SIZE=+1><FONT COLOR="#245CD2">Rainfall </font><FONT SIZE=+0> (since midnight)</td><td><FONT COLOR="#245CD2">0.00 in. (0.0 mm) ---</font></FONT></td></tr>
<tr><td><FONT SIZE=+1>Rainfall <FONT SIZE=+0>This month </td><td>0.00 in. (0.0 mm) </FONT></td>
<td><FONT SIZE=+1>Rainfall <FONT SIZE=+0>To date this year </td><td>0.00 in. (0.0 mm)</FONT></td></tr>
<tr><td><FONT SIZE=+1>Maximum rain per minute <FONT SIZE=+0> (last hour)</td><td>0.00 in/min </FONT></td></td>
<td><FONT SIZE=+1>Maximum rain per hour <FONT SIZE=+0> (last 6 hours)</td><td>0.00 in/hour</FONT></td></tr></td>
<tr><td><FONT SIZE=+1><font color="#FF9900">Yesterdays rainfall </font></td><td><font color="#FF9900">0.00 in</font></FONT></td>
<td><FONT SIZE=+1>DewPoint </td><td><font color="#FF9900">2.3&deg;C (Wet Bulb :3.2&deg;C )</font></FONT></td></tr>
<tr><td><FONT SIZE=+1>Humidity </td><td>90 %, Humidex 2.3 &deg;C</FONT></td>
<td><FONT SIZE=+1><font color="#CC33CC">Barometer </font><FONT SIZE=+0>corrected to msl</td><td><font color="#CC33CC">1021.0 mb</font></FONT></td></tr>
<tr><td><FONT SIZE=+1>Pressure change </td><td>0.0 mb  (last hour)</FONT></td>
<td><FONT SIZE=+1>Trend (last hour)</td><td>STEADY</FONT></td></tr>
<tr><td><FONT SIZE=+1>Pressure change <FONT SIZE=+0> (last 12 hours)</td><td>-3.0 mb</FONT></td>
<td><FONT SIZE=+1>Pressure change <FONT SIZE=+0> (last 6 hours)</td><td>-3.0 mb</FONT></td>
</table></center>
Now, the details above (last reading, temperature, etc) obviously change every 5 minutes too (same as the script created image). How can I link a page on my website to these above changing details on another website and then format the text to my styles and use only the text which I need (around half of what is above)?

I hope I have made my dillema clear .
EViS is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-21-2007, 01:06 AM Re: Link Some Details From One HTML Page To Another?
Experienced Talker

Posts: 39
Name: Andrew
Trades: 0
This is just a quick overview of how you could do it - unfortunately I don't have the time to do this slowly or the experience to do it quickly... Essentially, you need to load the weather web page and then extract bits from it.

Loading the page
The best (and perhaps only) way to do this is server side. cURL is a popular library in php that would work. It may be possible to do it client side via XMLHttpRequest (there are a lot of nice high level wrappers for this now like this one), though most browsers will block cross domain access. (So if the weather server is on a different domain from yours, it won't work.) Of course you could always do both - have php pull the data and then load it from your site with some funky AJAX code.

Extracting bits
Both php and JavaScript (and lots of other languages) allow you to use regular expressions to pull segments out of a string. (Look at preg_match and match.) For instance, run a search for 'humidity' and get the substring from that until the second </td> after that. Then strip the tags (php = strip_tags()) and you've got what you want. Note that this is unlikely to be robust - if they change the site, it will probably break your reg exps.

Having said all that, it's probably a lot easier to track down your weather data from another source designed for machines to read. That would certainly be my preferred option (You may also be breaking their TOS by scraping the site.)

Hmmm... Not sure if that helps or not.
__________________

Please login or register to view this content. Registration is FREE
- Pole dancing evolved
meloncholy is offline
Reply With Quote
View Public Profile
 
Old 12-21-2007, 04:21 AM Re: Link Some Details From One HTML Page To Another?
Average Talker

Posts: 24
Trades: 0
Thankyou for the reply so far. I am in good contact with that sites webmaster therefore once I find a good method for doing this I will of course ask the webmaster for his permission again .
EViS is offline
Reply With Quote
View Public Profile
 
Old 12-21-2007, 02:09 PM Re: Link Some Details From One HTML Page To Another?
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
Ive screwed around with some stuff in the past which "might" work, although it wont be pretty.

In php theres the fopen() function which if i remember correctly can open pages off other sites.

Google uses JS to put there google ads on your site. Although Im useless with java so I wont begin to give you advice on that :P.

Another ugly way which im not completely sure if it works is to make an html frame and have it take the information directly from his site. He probably is just including that side bar. Or if hes friends with you maybe he can just seperately host that part so you can steal it (assuming that works).
Truly is offline
Reply With Quote
View Public Profile
 
Old 12-21-2007, 03:36 PM Re: Link Some Details From One HTML Page To Another?
Experienced Talker

Posts: 39
Name: Andrew
Trades: 0
Actually, using an iframe is not a bad idea. It's not the nicest solution, but it would be reeeeally easy at your end.

Or you could perhaps use the image as before, but size it dynamically. Also nice and easy:

PHP Code:
<?php
list($width$height$type$attr) = getimagesize("http://www.example.com/weather.jpg");
echo 
"<img src=\"http://www.example.com/weather.jpg\" $attr alt=\"Weather image\" title=\"Want to know what the weather is doing right now?  No window?  We're here to help.\" />";
?>
__________________

Please login or register to view this content. Registration is FREE
- Pole dancing evolved
meloncholy is offline
Reply With Quote
View Public Profile
 
Old 12-23-2007, 11:02 PM Re: Link Some Details From One HTML Page To Another?
Novice Talker

Posts: 8
Name: Chris
Location: Swindon
Trades: 0
Well, it may be that you're trying to put it into a fixed table that is simply far to small for it. I didn't look through that code you provided because its 4am, and I'm off to bed soon.

However, as previously stated, iFrame is an easy, and pretty tidy way, of doing things like that. It will allow you to put the iFrame to the size of the image, or a bit bigger to make sure its a good fit.

You can find iFrame code, and iFrame code generators all over the web.

There are of course better ways than this I expect (only just come back into web design after being out of it for a year or so, so its only really a vague memory in my mind right now), but I'm not sure, and as I said, its 4am, I'm tired, And about to hit the hay, so good luck in sorting it if my idea didnt work
Lorem-Ipsum is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Link Some Details From One HTML Page To Another?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33651 seconds with 12 queries