yql 链接列表到 html
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几种方法可以做到这一点,具体取决于您想要采用哪种方法。
首先,也是最简单的,是服务器端生成。例如,如果用户点击搜索表单上的“提交”按钮向您发送他的查询,您的脚本将接收该查询并生成页面,然后将该页面发送给用户。在这种情况下,你的问题基本上是微不足道的。用伪代码表示:
这很简单,我怀疑您想通过 DOM 操作 来完成此操作。这就是需要 JavaScript 的地方:您获取查询,发送请求而不刷新页面,并将结果添加到 DOM。如果您收到结果列表,那么您已经完成了大部分工作。使用 jQuery,您将执行与上面的伪代码中相同的操作,除了它具有
PRINT
语句的地方:我强烈建议您阅读 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: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:I highly recommend reading through the jQuery tutorial. It's not as hard as you think.