我可以从谷歌搜索中获取JSON LD数据吗?

时间:2018-01-10 18:09:55

标签: javascript node.js json-ld

我希望能够与Alexa的AWS Lambda函数一起玩,并且想知道我是否可以提取填充第一道路日历站点的JSON LD事件数据?

https://www.google.com/search?q=first+avenue+calendar&oq=first+avenue+calendar&aqs=chrome.0.69i59j69i60l3j0l2.3727j0j7&sourceid=chrome&ie=UTF-8

我不确定这是否可能或从哪里开始,有什么想法?

1 个答案:

答案 0 :(得分:0)

刮除这些数据虽然不可靠,但微不足道。应该在chrome开发人员工具中运行几行JS代码:

这是让你入门的东西(每次谷歌更新他们的搜索时,类名_Kjf和Kjg都需要更新,因此不可靠):

let obj = [];
for (const n of document.getElementsByClassName('_Kjf')) {
    const date = n.getElementsByClassName('_Kjg')[0].innerText;
    const title = n.getElementsByClassName('title')[0].innerText;
    const time = n.getElementsByClassName('_Jjg')[0].innerText;
    obj.push({date, time, title});
}
console.log(JSON.stringify(obj, null, 2));

结果:

[
  {
    "date": "Tue, Jan 16",
    "time": "7:00 PM",
    "title": "YUMI ZOUMA"
  },
  {
    "date": "Wed, Jan 17",
    "time": "7:00 PM",
    "title": "ASHLEY GROVES Album Release Show"
  },
  {
    "date": "Thu, Jan 18",
    "time": "7:00 PM",
    "title": "SLØTFACE"
  },
  {
    "date": "Fri, Jan 19",
    "time": "9:00 PM",
    "title": "A DJ Tribute to THE PURPLE ONE and THE KING OF POP ft. DJ DAVE PAUL and DJ MARCO"
  },
  {
    "date": "Sat, Jan 20",
    "time": "8:00 PM",
    "title": "THE FUNK HUNTERS"
  },
  {
    "date": "Sun, Jan 21",
    "time": "7:00 PM",
    "title": "NEON DREAMS"
  },
  {
    "date": "Mon, Jan 22",
    "time": "7:00 PM",
    "title": "TY DAVIS - ARTeries Release Show"
  },
  {
    "date": "Wed, Jan 24",
    "time": "7:00 PM",
    "title": "DRIFTWOOD PYRE, SEAFARER, THE CULT OF LIP, and BLACK SATORI"
  },
  {
    "date": "Thu, Jan 25",
    "time": "7:00 PM",
    "title": "LAST IMPORT Release Show"
  },
  {
    "date": "Fri, Jan 26",
    "time": "8:00 PM",
    "title": "RYAN KINDER"
  },
  {
    "date": "Sat, Jan 27",
    "time": "8:00 PM",
    "title": "YUNG GRAVY"
  },
  {
    "date": "Sun, Jan 28",
    "time": "7:30 PM",
    "title": "MAKO - Breathe Tour"
  },
  {
    "date": "Mon, Jan 29",
    "time": "7:30 PM",
    "title": "VINNY CROOK$"
  },
  {
    "date": "Tue, Jan 30",
    "time": "7:30 PM",
    "title": "BLACK GENESIS"
  },
  {
    "date": "Wed, Jan 31",
    "time": "9:00 PM",
    "title": "Beyoncé vs Rihanna Dance Party"
  },
  {
    "date": "Wed, Feb 7",
    "time": "8:00 PM",
    "title": "Magic Giant"
  },
  {
    "date": "Thu, Feb 8",
    "time": "8:00 PM",
    "title": "ZZ Ward"
  },
  {
    "date": "Fri, Feb 9",
    "time": "8:00 PM",
    "title": "flor"
  },
  {
    "date": "Sun, Feb 11",
    "time": "8:00 PM",
    "title": "Flint Eastwood"
  },
  {
    "date": "Tue, Feb 13",
    "time": "5:30 PM",
    "title": "Neck Deep"
  },
  {
    "date": "Wed, Feb 14",
    "time": "8:00 PM",
    "title": "Rostam"
  },
  {
    "date": "Fri, Feb 16",
    "time": "9:00 PM",
    "title": "Rebelution"
  },
  {
    "date": "Sat, Feb 17",
    "time": "8:00 PM",
    "title": "Valerie June"
  },
  {
    "date": "Tue, Feb 20",
    "time": "8:30 PM",
    "title": "Majid Jordan"
  },
  {
    "date": "Wed, Feb 21",
    "time": "8:00 PM",
    "title": "Polica"
  },
  {
    "date": "Thu, Feb 22",
    "time": "8:00 PM",
    "title": "Machine Head"
  },
  {
    "date": "Fri, Feb 23",
    "time": "8:00 PM",
    "title": "ANI DIFRANCO with Gracie and Rachel"
  },
  {
    "date": "Sat, Feb 24",
    "time": "9:00 PM",
    "title": "Porches."
  },
  {
    "date": "Wed, Feb 28",
    "time": "8:30 PM",
    "title": "Autograf"
  },
  {
    "date": "Fri, Mar 2",
    "time": "9:00 PM",
    "title": "Tune-Yards"
  },
  {
    "date": "Mon, Mar 5",
    "time": "8:00 PM",
    "title": "EarthGang"
  },
  {
    "date": "Tue, Mar 6",
    "time": "7:00 PM",
    "title": "Why Don't We"
  }
]