Getting data from a web page

Getting data from a web page

am 30.01.2008 21:34:03 von laredotornado

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=980+PEMART+AVE+PEEKSKILL,+ NY+10566&output=csv&key=ABQIAAAAuHEWowxYzDRtZwy5bJee6RRepaxJ 09NBCcZ4ddHPnTvG1CBwlxTqGOXX0DHtp5WHcsP7cJ-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

Re: Getting data from a web page

am 30.01.2008 22:10:46 von ivansanchez-alg

laredotornado@zipmail.com wrote:

> http://maps.google.com/maps/geo?q=980+PEMART+AVE+PEEKSKILL
+NY+10566&output=csv&key=ABQIAAAAuHEWowxYzDRtZwy5bJee6RRepax J09NBCcZ4ddHPnTvG1CBwlxTqGOXX0DHtp5WHcsP7cJ-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).

Re: Getting data from a web page

am 30.01.2008 22:13:19 von Larry Anderson

On Jan 30, 12:34 pm, "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=980+PEMART+AVE+PEEKSKILL,+ 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.

Re: Getting data from a web page

am 31.01.2008 00:39:13 von Manuel Lemos

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=980+PEMART+AVE+PEEKSKILL,+ NY+10566&output=csv&

key=ABQIAAAAuHEWowxYzDRtZwy5bJee6RRepaxJ09NBCcZ4ddHPnTvG1CBw lxTqGOXX0DHtp5WHcsP7cJ-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=ABQIAAAAuHEWowxYzDRtZwy5bJee6RRepaxJ09NBCcZ4ddHPnTvG1CB wlxTqGOXX0DHtp5WHcsP7cJ-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/

Re: Getting data from a web page

am 31.01.2008 00:46:00 von zeldorblat

On Jan 30, 3:34 pm, "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=980+PEMART+AVE+PEEKSKILL,+ 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));

Re: Getting data from a web page

am 31.01.2008 04:34:42 von nc

On Jan 30, 12:34 pm, "laredotorn...@zipmail.com"
wrote:
>
> If I type this URL into my browser:
>
> http://maps.google.com/maps/geo?q=980+PEMART+AVE+PEEKSKILL,+ 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