473,385 Members | 1,919 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,385 software developers and data experts.

Pull part of an external webpage into another

3
Hi! This is my first post...and when I begin working on this project, it will also be my first PHP project! I do have some programming experience from my first year at college, but that was in Scheme :-). I have not started work on this problem yet, because I am still doing research and figuring out how I can do it using PHP. My goal is to turn this into a Joomla module that I can offer for free on Joomla.org and use on a few of the websites I create. So here is the overview of the problem: at this location [HTML]http://apps.cbp.gov/bwt/index.asp[/HTML] there is a website that has all of the border wait times for the US for both Canadian and Mexican ports of entry. In particular, I am interested in the Calexico ports, but I am sure I can generalize the problem enough to allow any of the other ports to be chosen as well. I want to use PHP to save a local copy of the page on the server, or alternately, to grab the page, parse it for the parts that are needed, and only cache that portion on the webpage (the cache or local copy would have to expire after only a few minutes, but that would at least minimize redundant calls for every page reload on my site, I figure). I know that cURL or fopen (I have both working on my server) allow you to grab external webpages, but I don't really know what I would need to do from there. How do I parse the page to only keep what I need? How can I set PHP to only run the function every couple of minutes, rather than every time the page loads? Those are my main questions, so if anybody could help point me in the right direction to some functions or webpages I could use they would be much appreciated :-).

-Omar
Oct 28 '06 #1
4 4654
ronverdonk
4,258 Expert 4TB
Many government orgs offer rss feeds (xml) that you can tap into. Are you sure that this cannot be done via an rss feed from that organization?

Ronald :cool:
Oct 28 '06 #2
orware
3
Thanks for the idea! Not that I would have any idea about what to do with the feed, but because of the XML I'm sure it would have been easier to parse through. I went to see the main area of the site, and checked out the RSS feeds, but the ones available are not related to the border wait times. Also, the page I referred to in my last post is on a subdomain...apps.cbp.gov, and they only have one other script (one for airport wait times), but no feeds that go along with them.

As I continued my research I read an article about output buffering that should prove helpful, however I still do not know how to parse a page to extract the data that I need. Again, any helpful functions you can mention would lower my search time reading up on php.net :-).

-Omar
Oct 28 '06 #3
ronverdonk
4,258 Expert 4TB
If you'd have an RSS feed, you could tap into it and extract the info (xml structured) into a buffer and parse for info that you are looking for. For now, you'll have to 'scrape' a web page. Have a look at the following free php class at Scraper class that provides scraper functions.

Its description states:
This class is meant to fetch remote HTML pages and parse them to extract structured information into arrays.

It can take a model of the definition of the structure of a given page and process it to clip the relevant fields of information.
Ronald :cool:
Oct 28 '06 #4
orware
3
Nice...I'll take a look at it and I'll post back :-).

Thank you!

-Omar Ramos
Oct 29 '06 #5

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

Similar topics

14
by: Richard Speiss | last post by:
I am trying to display a random background image for a webpage. I found this code to do it <% 'Defines the number of background images you have Const NUMBER_OF_IMAGES = 2 'Initiates the...
5
by: Glenn Mulno | last post by:
Hi, I am trying to create a report page for several teams. Each team runs the same reports but the reports use different values. For a while this was getting insane everytime I updated the...
5
by: bobbyd | last post by:
Hi All, Does anyone know of a way to read an output from an external webpage/service? For example; The external source is on http://serverA:6010/sendoutput This page displays one line of...
1
by: Daniel Di Vita | last post by:
I have an application that needs to pull files from an internal server. This is the setup. The web server is external facing, meaning exposed to the internet. I then have a file server that sits...
4
by: Giorgio | last post by:
hi, how can i include a webpage from another server with ASP? (Without frames) i tried XMLHTTP, but i loose the stylesheet, images src and relative links of the included page. See...
38
by: Neo Geshel | last post by:
I am seeking a method to load one JS file directly into another, *without* having to dynamically write <scripttags. Is there any method whereby I can call only one external JS file using a ...
7
by: Andrea | last post by:
Hi there! I have to do a php script that daily surf a webpage (I do it with crontab) and collect some data. The proble is that to access that webpage I have to do a login. I have the login data,...
5
by: Yarda | last post by:
Hello, I am new to php and databases, we have an intranet and I have installed apache, mysql and php. We want to index, catalog and serve mp3 files from a web page using the above mentioned...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.