473,320 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Extract content showed by IFrame, saving it in database

Hi everybody,

Asking for some help over here.

My issue is that I´m looking how to copy or extract a particular table content of a website. I get the content from a external feed provider (Iframe format), the content is updated every minute. The Iframe updates new results and for instance, could show from 20 to 100 lines in the table in average at any moment.

Since the information showed by the feed is dynamic, I can´t look for old results(e.g. last week, month, etc) Thus, my goal, (if it´s possible) have a script to read/copy the content within IFrame periodically (e.g twice a day) and it sends it to a MySQL database, within the hosting server. With this would be possible build a results history and be able to show old results
of desired events in any moment when visitors want.

The IFrame table shows something like this:

Expand|Select|Wrap|Line Numbers
  1. Country 1: Place
  2. 04-12-2010 20:45 - cloudy - partly cloudy  Now    
  3. Country 2: Place
  4. 04-12-2010 19:00 - cloudy - cloudy  Now
  5. .
  6. .
  7. .
  8. Country N: Place
  9. 04-12-2010 17:30 - Sunny - Partly cloudy  Now
  10.  
In summary:
It´s possible to extract/get the content that is within the table generated by IFrame, within the website where thw IFrame is showed?

Many thanks for any advice or help with this.

Best regards.
Apr 19 '10 #1
5 9898
Dormilich
8,658 Expert Mod 8TB
the content of an iframe is a website of its own.
Apr 19 '10 #2
Atli
5,058 Expert 4TB
Hey.

It may be easier to just pull the contents of the website being displayed in the <iframe> and parse it from there in PHP. You could use Curl or possibly just file_get_contents to pull the website, and then go through it with DOM or even SimpleXML. (Valid HTML can usually be parsed as XML)

If you need to do this using the <iframe>, you would need to use JavaScript.
Apr 19 '10 #3
Hi and thanks both Atli and Dormilich for your answer,

I´m newbie regarding web programming, actually the web I´ll trying to build is using Joomla, but I´ve learned some things about html, php so far in the process. But I don´t have enough knowledge yet to do this specific task on my own.

I´ve followed information from links you gave me (php.net) and I´ve tried some example codes about "file" and "file_get_content" functions, but I don´t know how to get the text content that is inside the IFrame which is seen by visitors. What I get is as follow:

1 -) Using the following code with "file_get_contents" function, the script loads the entire site as I would surf its URL directly in web browser.

Code using "file_get_contents" function:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if( false == ($Content=file_get_contents( 'http://www.mywebsite.com' )))
  3.     echo "Could not read file.";
  4.   else
  5.     echo "File contents: $Content";
  6. ?> 

2 -)
Using the following code with "file" function, the script looks like loads the HTML code of the page, but in the part where I was expecting or which is supposed to show the text contained within IFrame, It only shows the IFrame Script. I mean:

Code using "file" function:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Get a file into an array.  In this example we'll go through HTTP to get
  3. // the HTML source of a URL.
  4. $lines = file('http://www.mywebsite.com/');
  5.  
  6. // Loop through our array, show HTML source as HTML source; and line numbers too.
  7. foreach ($lines as $line_num => $line) {
  8.     echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
  9.  

Result: HTML code, and only IFrame code.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  2.  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">
  3.  <head>
  4. .
  5. .
  6. <iframe id="Iframe_title" frameborder="0" style="width:400px; height:150px;" src="/" allowtransparency="true"></iframe>
  7. <script type="text/javascript" src="http://www.source-of-iframe.com/js/Iframe_title.js?p=328&s=1&l=3&h=www.source-of-iframe.com"></script> 
  8.  
  9. </div>
  10. .
  11. .
  12. .
  13. </body> 
  14. </html> 
Maybe somebody has done something similar before to give me some tips or a kind of example on how to follow.

Many thanks in advance for any help.

Best regards,
Apr 19 '10 #4
Dormilich
8,658 Expert Mod 8TB
it may well be that the iframe only contains a script, which is responsible for creating the HTML content. in this case you can’t do anything about it, since PHP does not execute JavaScript.
Apr 19 '10 #5
Thanks Dormilich for reply,

Well, if it not possible to extract the HTML content within the IFrame with PHP, how could be possible using javascript to run a script within some location inside the server?

Is there some place where can I see similar examples regarding this?.

I´ve searched in search engines without get what I´m looking for yet, maybe due I´m not using the correct word concepts or searching in the wrong programming language.

Many thanks again.

Best regards,
Apr 19 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Andres Mas Torrecillas | last post by:
Hi! I'm having a little trouble with an IFRAME added in an HTML page. IFRAME has a fixed size and it contains another HTML page, which only has some text paragraphs and a pair of images aligned...
7
by: Lorenzo Vaina | last post by:
Can i get the content of an URL and put it in a variable using javascript? I want js execute different operations varying a file that is on internet. Thanks, regards.
10
by: mark4 | last post by:
Hello, Are there any utilities to help me extract Content from HTML ? I'd like to store this data in a database. The HTML consists of about 10,000 files with a total size of about 160 Mb....
2
by: mike | last post by:
I have a page with a form as follows: <form name="updfrm" method="post" action="update_db.cfm"> <input type="text" name="myfield" value="stuff"> <button onclick="sub_this();">press here</button>...
1
by: Rhys | last post by:
I have a page which has an IFrame on it. The src of the IFrame is a page with a datagrid on it. The Datagrid has bound template columns. The columns of the datagrid pass the bound data value of...
1
by: bjorn2k | last post by:
Hi All, I'm working on a webpage. In this webpage i have an IFrame. I load html files in this I frame, but then i get those scrollbars which i want to get rid off. My Iframe has a fixed width....
9
by: aatcbbtccctc | last post by:
Hi folks I've googled for an answer to this, with no success. Can someone please jump in, and put me out of my misery! (I'm sure it's quite simple) I have an invisible IFRAME, and a visible...
1
by: Chris | last post by:
If this is not the right place to post, please someone direct me to the correct place. I'm having problems extracting the binary data that's included in an xml response back from a server. It's...
6
by: Duncan | last post by:
Does anybody know how the following can be acheived using html or xhtml? I need to present colleagues with a 'to-do' list. Lets say the list has ten or so jobs and each job consists of five or...
0
by: centur | last post by:
I need to acquire content body of MIME encoded message (as IMessage object).I want using C# and CDO Interop extract such data ("eJ8+IggVAQaQ..." unicode part). Here is example of Bodypart...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.