1
我的任务是尽我所能下载尽可能多的楼盘优惠。我有用于下载链接和其他内容的脚本,但我无法获得单位坐标(这对我来说至关重要,我的分析重点)。获取房地产业务
坐标显示在网站上(通过检查谷歌地图元素),但不在网站的源代码中。
当我使用下面的R代码时,我得到一个空列表,如果我使用XML或RCurl包,则没有区别。
你认为这是可能实现这一目标用R或我应该对其他编程语言的东西(如Python的?)
library(XML)
library(RCurl)
url<-'http://en.otodom.pl/flat-poznan-jezyce-2720m2-2-rooms-125000-pln-id13250586.html'
doc<-htmlParse(url,encoding='utf-8')
xpathApply(doc,'//div[@id="googleMap"]',xmlGetAttr,'data-map')
#the same result
doc<-getURL(url, httpheader = c('User-Agent' = "Informative string with your contact info"),.encoding='utf-8')
doc<-htmlParse(doc,encoding='utf-8')
xpathApply(doc,'//div[@id="googleMap"]',xmlGetAttr,'data-map')
# the same here
doc<-getURL(url, followlocation=T)
doc<-htmlParse(doc,encoding='utf-8')
xpathApply(doc,'//div[@id="googleMap"]',xmlGetAttr,'data-map')
非常感谢你,这就是我需要的! – Maciej 2012-04-26 05:06:47
很高兴有用@Maciej。 :)当然,这取决于您是否合法地抓取网站并将数据用于您的目的,以及成为一名优秀的公民并调整您的查询速度,以便您不会泛滥网站。 .. – gauden 2012-04-26 05:55:55