R 中的动态网页抓取

问题描述 投票:0回答:1

我正在尝试在 R 中抓取有关小行星轨道的信息。我尝试过 rvest 和selectorgadget,但是该网站是动态的。网站是:https://ssd.jpl.nasa.gov/tools/sbdb_lookup.html#/?sstr=2006%20WP1

我想要获取此处显示的轨道参数下拉列表下密切轨道元素的数据:

我对 html 或 json 不太熟悉,所以我正在寻求帮助将此表下载到 R 中。

html r json tidyverse rvest
1个回答
0
投票

使用他们的API。在页面中可以看到该对象有一个skp标识符

3359266

spkid <- "3359266"

dat <- jsonlite::fromJSON(sprintf("https://ssd-api.jpl.nasa.gov/sbdb.api?spk=%s", spkid))

dat$orbit$elements

   units   sigma       value                                                 title name  label
1   <NA>  0.0011       0.607                                          eccentricity    e      e
2     au  0.0037        1.71                                       semi-major axis    a      a
3     au 0.00037       0.671                                   perihelion distance    q      q
4    deg  0.0094         5.9 inclination; angle with respect to x-y ecliptic plane    i      i
5    deg 0.00085         234                       longitude of the ascending node   om   node
6    deg  0.0079        98.2                                argument of perihelion    w   peri
7    deg   0.087        22.1                                          mean anomaly   ma      M
8    TDB   0.034 2454008.477                            time of perihelion passage   tp     tp
9      d     2.6         815                               sidereal orbital period  per period
10 deg/d  0.0014       0.442                                           mean motion    n      n
11    au  0.0059        2.74                                     aphelion distance   ad      Q
© www.soinside.com 2019 - 2024. All rights reserved.