如何获取按给定 XPATH 排序的 YQL 的 JSON 结果

发布于 2024-11-17 16:09:35 字数 324 浏览 5 评论 0原文

我正在尝试抓取一个网站。
我使用 XPATH 进行了 YQL 查询,查询文章的标题、日期和正文

select * from html where url="mywebsite.com/myarticle" and xpath="headlineXpath | DateXpath | BodyXpath"

现在 xml 中的结果是标题、日期,然后是正文,这就是我正在寻找的。
但是当我得到 json 格式的结果时,我以另一种顺序得到它标题,正文然后日期 我的问题:如何根据给定 XPATHS 的顺序获取 json 中的结果?
感谢您的帮助

I am trying to crawl a website.
I have made my YQL query with XPATh for headline, Date, then Body of the article.

select * from html where url="mywebsite.com/myarticle" and xpath="headlineXpath | DateXpath | BodyXpath"

now the result in xml is headline, date, then body and this is what i am looking for.
but when i get the result in json format, i get it in another order headline, body then date
my question: how can i get the result in json according to the order of the given XPATHS?
thanks for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回眸一笑 2024-11-24 16:09:35

您是否尝试过:

select headline, date, body from html where ...

而不是使用*?我不太了解 YQL,所以我可能对参数不太了解,但想法是使用显式选择而不是通配符来指定字段的顺序。

Did you try:

select headline, date, body from html where ...

instead of using *? I don't know much YQL so I may be off on the arguments, but the idea is to specify the order of fields using explicit selection instead of the wildcard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文