Home > Archive > PHP Programming > January 2008 > Getting data from a web page
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Getting data from a web page
|
|
| laredotornado@zipmail.com 2008-01-30, 7:12 pm |
| Hi,
I'm using php 4.4.4. What I want to do is hopefully simple. If I
type this URL into my browser:
http://maps.google.com/maps/geo?q=9...r />
cJ-K0vvurg
I get a simple comma-delimited list of data. What I would like to do
is in my PHP script, request this URL and then put the return values
into an array. How do I do this?
Thanks, - Dave
| |
| Iván Sánchez Ortega 2008-01-30, 7:12 pm |
| laredotornado@zipmail.com wrote:
> http://maps.google.com/maps/geo?q=9...T+AVE+PEEKSKILL
+NY+10566&output=csv& key=ABQIAAAAuHEWowxYzDRtZwy5bJee6RRepaxJ
09NBCcZ4ddHPnTvG1CBwlxTqGOXX0DHtp5WHcsP7
cJ-K0vvurg
>
> I get a simple comma-delimited list of data. What I would like to do
> is in my PHP script, request this URL and then put the return values
> into an array. How do I do this?
Use CURL functions to get the data, then use string functions to parse the
data into an array.
Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
God is real (unless declared integer).
| |
| larry@portcommodore.com 2008-01-30, 7:12 pm |
| On Jan 30, 12:34 pm, "laredotorn...@zipmail.com"
<laredotorn...@zipmail.com> wrote:
> Hi,
>
> I'm using php 4.4.4. What I want to do is hopefully simple. If I
> type this URL into my browser:
>
> http://maps.google.com/maps/geo?q=9...L,+NY+10566&...
>
> I get a simple comma-delimited list of data. What I would like to do
> is in my PHP script, request this URL and then put the return values
> into an array. How do I do this?
>
> Thanks, - Dave
You will want to read up on the CURL library and the term scrape or
google for curl and scrape, that should give you hits on what you want
to do.
Scrape sounds kinda bad and if you don't have permission to read
someones data off a page you could get in trouble. Google has
information aout what you can collect from their pages and for what
purpose.
| |
| Manuel Lemos 2008-01-30, 7:12 pm |
| Hello,
on 01/30/2008 06:34 PM laredotornado@zipmail.com said the following:
> I'm using php 4.4.4. What I want to do is hopefully simple. If I
> type this URL into my browser:
>
> http://maps.google.com/maps/geo?q=9...566&output=csv&
key=ABQIAAAAuHEWowxYzDRtZwy5bJee6RRepaxJ
09NBCcZ4ddHPnTvG1CBwlxTqGOXX0DHtp5WHcsP7
cJ-K0vvurg
>
> I get a simple comma-delimited list of data. What I would like to do
> is in my PHP script, request this URL and then put the return values
> into an array. How do I do this?
For simple requests like that, you can just call:
$csv = file_get_contents('http://maps.google.com/maps/geo?
q=980+PEMART+AVE+PEEKSKILL,+NY+10566&output=csv
& key=ABQIAAAAuHEWowxYzDRtZwy5bJee6RRepaxJ
09NBCcZ4ddHPnTvG1CBwlxTqGOXX0DHtp5WHcsP7
cJ-K0vvurg');
--
Regards,
Manuel Lemos
PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
| |
| ZeldorBlat 2008-01-30, 7:12 pm |
| On Jan 30, 3:34 pm, "laredotorn...@zipmail.com"
<laredotorn...@zipmail.com> wrote:
> Hi,
>
> I'm using php 4.4.4. What I want to do is hopefully simple. If I
> type this URL into my browser:
>
> http://maps.google.com/maps/geo?q=9...L,+NY+10566&...
>
> I get a simple comma-delimited list of data. What I would like to do
> is in my PHP script, request this URL and then put the return values
> into an array. How do I do this?
>
> Thanks, - Dave
$url = 'http://maps.google.com/maps/geo?q=980+PEMART+AVE+PEEKSKILL,+NY
+10566&...';
$arr = explode(',', file_get_contents($url));
| |
|
| On Jan 30, 12:34 pm, "laredotorn...@zipmail.com"
<laredotorn...@zipmail.com> wrote:
>
> If I type this URL into my browser:
>
> http://maps.google.com/maps/geo?q=9...L,+NY+10566&...
>
> I get a simple comma-delimited list of data. What I would like to do
> is in my PHP script, request this URL and then put the return values
> into an array. How do I do this?
$URL = 'http://maps.google.com/maps/geo?q=...';
$dataArray = explode(',', trim(file_get_contents($URL)));
Cheers,
NC
|
|
|
|
|