yql 链接列表到 html

发布于 2024-10-05 02:13:10 字数 259 浏览 6 评论 0原文

我正在使用 yql 返回特定网页的链接列表。到目前为止一切顺利,它返回了我假装的所有链接,但是我不知道如何将该信息翻译到我的网页中。

这就是我想要做的:

  • YQL 返回中的链接列表 结果
  • 我希望这些链接出现在我的 网页、表格内、div 内、 等等...就像我把它们写在那里一样。

我一直在尝试找到一种方法来做到这一点,但我对 js 和 json 不太了解,所以我在这里试图从那些可能知道方法的人那里得到一些答案。

I'm using yql to return a list of links from specific webpages. So far so good, it returns all the links that I pretend, however I don't know how to translate that info into my webpage.

Here's what I'm trying to do:

  • YQL returns a list of links in the
    results
  • I want those links to appear in my
    webpage, inside a table, inside divs,
    etc... like if i wrote them there.

I have been trying to find a way to do this but I don't know much of js and json so I'm here trying to achieve some answer from those of you that might know a way.

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

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

发布评论

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

评论(1

亽野灬性zι浪 2024-10-12 02:13:10

有几种方法可以做到这一点,具体取决于您想要采用哪种方法。

首先,也是最简单的,是服务器端生成。例如,如果用户点击搜索表单上的“提交”按钮向您发送他的查询,您的脚本将接收该查询并生成页面,然后将该页面发送给用户。在这种情况下,你的问题基本上是微不足道的。用伪代码表示:

ASSIGN the list of results to list L
FOR EACH ITEM r IN L
    PRINT a string containing an HTML template, substituting the value 
          r where appropriate

这很简单,我怀疑您想通过 DOM 操作 来完成此操作。这就是需要 JavaScript 的地方:您获取查询,发送请求而不刷新页面,并将结果添加到 DOM。如果您收到结果列表,那么您已经完成了大部分工作。使用 jQuery,您将执行与上面的伪代码中相同的操作,除了它具有 PRINT 语句的地方:

$(".SearchResults").append("<li>" + r + "</li>");

我强烈建议您阅读 jQuery 教程。这并不像你想象的那么难。

There are a couple of ways to do this, depending on which approach you want to take.

First, and simplest, is server-side generation. This is what would result, for example, if a user hits a Submit button on a search form to send you his query, your script receives the query and generates the page, then sends that page to the user. In this case, your question is largely trivial. In pseudocode:

ASSIGN the list of results to list L
FOR EACH ITEM r IN L
    PRINT a string containing an HTML template, substituting the value 
          r where appropriate

It's trivial enough that I suspect you want to do this via DOM manipulation. This is what requires JavaScript: you get the query, send the request without refreshing the page, and want to add the results to the DOM. If you're receiving the list of results, you're already most of the way there. Using jQuery, you would do the same thing as in the pseudocode above, except that where it has the PRINT statement you would have:

$(".SearchResults").append("<li>" + r + "</li>");

I highly recommend reading through the jQuery tutorial. It's not as hard as you think.

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