By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Web clipping of a "remote" web page for insertion into a "local" page: is it possible?

P: n/a
What I am trying to do is grab a little snippet of data from a remote
page based on user input in a form. Take a look at this page:
http://www.qrz.com/kb2gsd

What I want to do is: when a user types the call sign (in this case,
KB2GSD) into a form field, I want to execute an XPath query (or somehow
otherwise process the contents of the page)
to automatically complete the Name, Location, etc. fields in my "local"
page from a "remote" web
page like the one listed above.

Is this possible with PHP? If so, what functions, libraries, etc. do I
need to read about in order to do this? I have searched a good deal for
examples/previously asked questions about this, but with little
success. What search terms might I use to find out a bit more about
this?

Thanks for reading and thanks for a response if you're able to help.

Dec 12 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

soren625 wrote:
What I am trying to do is grab a little snippet of data from a remote
page.....
This is typically referred to as "scraping"

see fopen or even file_get_contents
http://us3.php.net/manual/en/function.fopen.php
These functions will open a webpage just like a local file
Then you can do whatever.
see the string functions
http://us3.php.net/manual/en/ref.strings.php
or regular expression funcs
http://us3.php.net/manual/en/ref.pcre.php

Dec 12 '06 #2

P: n/a


On Dec 12, 10:58 am, "BKDotCom" <bkfake-goo...@yahoo.comwrote:
>...This is typically referred to as "scraping" ...

see fopen ... file_get_contents ...


Awesome ... yeah, I guess that is scraping ... that term had not come
to mind for some reason.

Thanks a million for the help.

Dec 12 '06 #3

P: n/a
Message-ID: <11**********************@j72g2000cwa.googlegroups .comfrom
BKDotCom contained the following:
>These functions will open a webpage just like a local file
Doesn't seem to work with this particular site unless I'm doing
something wrong

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Dec 12 '06 #4

P: n/a


On Dec 12, 11:17 am, Geoff Berrow <blthe...@ckdog.co.ukwrote:
>Doesn't seem to work with this particular site unless I'm doing
something wrong
I got it to work exactly as I needed:

--------- START OF PHP CODE ----------------------

$file = file_get_contents("http://www.qrz.com/detail/KB2GSD");
$name_pattern = '/Name:(.*)/';
preg_match($name_pattern, $file, $match);
echo strip_tags($match[1]).'<br />';

$city_pattern = '/Addr2:(.*),/';
preg_match($city_pattern, $file, $match);
echo strip_tags($match[1]).'<br />';

$country_pattern = '/Country:(.*)/';
preg_match($country_pattern, $file, $match);
echo strip_tags($match[1]).'<br />';

$state_pattern = '/State:(.*)/';
preg_match($state_pattern, $file, $match);
echo strip_tags($match[1]).'<br />';

$grid_pattern = '/Grid:(.*)/';
preg_match($grid_pattern, $file, $match);
echo strip_tags($match[1]).'<br />';

------------------ END OF PHP CODE -------------

Works like a charm! Thanks again!

Dec 12 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.