I have a CSV file that contains:
Name of Company; Complete Address(street name zip code etc)
And some other data.
I need to somehow extract a phone number in an automatic way since there are 30k rows.
I could search it up on google and get the usual company banner from google where there is the phone number but since there are 30k records I wanted to automate it also for future uses.
At first sight I thought of using Google API with Python/JavaScript/jquery and search up the place and retrieve from the JSON the details of the company with the phone number.
By for example doing an https request or a curl:
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?fields=formatted_address%2Cname%2Crating%2Copening_hours%2Cgeometry&input=AGENZIA+DI+FORMAZIONE+PROFESSIONALE+DELLE+COLLINE+ASTIGIANE+SIGLA+BILE+A.F.P.+COLLINE+ASTIGIANE+S.C.R.L.REGIONE+SAN+ROCCO+74+14041+AGLIANO+TERME+-+AT&inputtype=textquery&key="YOUR_API_KEY"
But the results are not what I’ve expected:
{
"candidates" :
[
{
"formatted_address" : "Regione S. Rocco, 74, 14041 Agliano AT, Italia",
"geometry" :
{
"location" :
{
"lat" : 44.8032127,
"lng" : 8.248341099999999
},
"viewport" :
{
"northeast" :
{
"lat" : 44.80456222989272,
"lng" : 8.24969852989272
},
"southwest" :
{
"lat" : 44.80186257010728,
"lng" : 8.246998870107277
}
}
},
"name" : "Agenzia di Formazione Professionale delle Colline Astigiane",
"opening_hours" :
{
"open_now" : false
},
"rating" : 4.6
}
],
"status" : "OK"
}
Or at least it seemed it found the place but not the info I need.
2
Answers
I found the solution to solve it. Seems like if you add also the formatted_phone_number or international_phone_number field to the request API will answer with:
So to avoid it you need to make actually two requests. In my case:
That will answer with :
Once you have the place_id you need to make another request. In my case :
That will give the full information on the indicated place. Seems a little weird since you have to make 2 separate requests instead of one, but this seems to be the only solution I found so far. Thanks for the help @mykaf and @geocodezip
The "formatted_phone_number" field is only available via a
PlacesService.getDetails
request.Per the documentation:
formatted_phone_number optional
Type: string optional
The Place’s phone number, formatted according to the number’s regional convention. Only available with PlacesService.getDetails.