使用PHP解析Googlemaps(Using PHP to parse Googlemaps)
我有一个网站,我屏幕上刮掉GoogleMaps以获得从一个点到另一个点的行车距离。 它没有被大量使用(每周最多20次请求),但Google最近的升级破坏了这一功能。
我以前用这个:
$url = 'http://maps.google.com/maps?f=d&hl=en&saddr='.$start.'&daddr='.$finish.'&output=xml';
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($ch); if(preg_match('!(\d+).*?.*?(\d+)[^\d]*(\d*)!si', $data, $matches))它会返回行驶距离和总时间。 新版本的GoogleMaps破坏了这一功能,我正试图找到一种处理新API的方法。
I have a site that I screen-scrape off GoogleMaps to get the driving distance from one point to another. It isn't heavily used (20 requests per week max), but Google's recent upgrade broke this functionality.
I used to use this:
$url = 'http://maps.google.com/maps?f=d&hl=en&saddr='.$start.'&daddr='.$finish.'&output=xml';
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($ch); if(preg_match('!(\d+).*?.*?(\d+)[^\d]*(\d*)!si', $data, $matches))And it would return driving distance and total time. The new version of GoogleMaps broke this functionality and I'm trying to figure out a way to deal with the new API.
原文:https://stackoverflow.com/questions/3727799
更新时间:2023-11-24 14:11
最满意答案
相关问答
更多-
CSS:之前在内联SVG(CSS :before on inline SVG)[2023-07-11]
不,内联SVG被视为图像,而图像是被替换的元素 ,不允许生成内容 。 严格地说,我认为它是不确定的。 一般来说, CSS 2.1只是谈论“图像,嵌入式文档和小程序”, HTML标准定义了它的图像,而不是明确的SVG。 No, inline SVG is treated as an image, and images are replaced elements which are not allowed to have generated content. Strictly speaking, I think ... -
内联移动svg样式属性(Moving svg style properties inline)[2021-08-12]
可能这样会好的: