这是我正在使用的代码示例:
library(jsonlite)
library(curl)
#url
url = "http://www.zillow.com/search/GetResults.htm?spt=homes&status=001000<=000000&ht=010000&pr=999999,10000001&mp=3779,37788&bd=0%2C&ba=0%2C&sf=,&lot=0%2C&yr=,1800&singlestory=0&hoa=0%2C&pho=0&pets=0&parking=0&laundry=0&income-restricted=0&pnd=0&red=0&zso=0&days=36m&ds=all&pmf=0&pf=0&sch=100111&zoom=6&rect=-91307373,29367814,-84759521,35554574&p=1&sort=globalrelevanceex&search=maplist&rid=4&rt=2&listright=true&isMapSearch=true&zoom=6"
#json
results_data_json = fromJSON(txt = url)
Run Code Online (Sandbox Code Playgroud)
我曾经能够运行类似的代码,没有任何问题.现在我收到以下错误:
Error in feed_push_parser(buf) :
lexical error: invalid char in json text.
<html><head><title>Zillow: Real
(right here) ------^
Run Code Online (Sandbox Code Playgroud)
围绕这个想法吗?
我从文件中读取 JSON 时发生了这种情况。该代码有一天有效,然后第二天我收到此错误。尽管我不明白为什么我的解决方案有效,但我最终能够规避该错误。我发现一个 GitHub 帖子建议添加 readLines() 函数。例如。
r_object <- fromJSON(readLines("file.json"), warn = F)
Run Code Online (Sandbox Code Playgroud)
“warn”参数设置为 FALSE,以抑制由于许多 JSON 文件中缺少最终 EOL 而触发的警告消息。
我也无法复制错误。
class(results_data_json)
[1] "list"
Run Code Online (Sandbox Code Playgroud)
我的会话信息:
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7600)
locale:
[1] LC_COLLATE=Spanish_Colombia.1252 LC_CTYPE=Spanish_Colombia.1252 LC_MONETARY=Spanish_Colombia.1252
[4] LC_NUMERIC=C LC_TIME=Spanish_Colombia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] curl_2.4 jsonlite_1.1
loaded via a namespace (and not attached):
[1] tools_3.3.2
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12103 次 |
最近记录: |