“固定它”按钮源代码 (pinterest.com)
有谁知道如何在 pinterest.com 中实现“PIN IT”按钮之类的功能? 从高层来看,我了解它的作用,但不详细。您单击“固定它”书签,然后抓取网站源代码以查找宽度和高度大于某个阈值的图像。抓取页面源以查找图像可以发生在客户端或服务器端。实现类似目标的最佳方法是什么?
有人可以深入了解他们的实施吗?
Does anyone have idea about how to implement something like "PIN IT" button in pinterest.com?
From a high-level, I understand what it does but not in detail. You click on "pin it" bookmark, and then you scrape the site source code to find out images with width and height greater than some threshold. The scraping of the page source to find images can happen on the client side or on the server side. What's the best way to achieve something similar?
Could some one throw insight into their implementation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上这种书签通常是这样做的:
当你点击书签时,它会通过重定向到以下 URL 来运行 JavaScript 代码:
然后 SOME_CODE 将执行。在这种情况下,固定按钮将运行如下:
这最终将向文档正文添加新标签。 Pin 它将添加“pinmarklet.js”文件。请注意,“?r=' + Math.random() * 99999999”部分仅用于通过每次随机生成新数字从客户端传递缓存来获取。
如果你想确切地了解接下来发生了什么,那么你需要查看他们的 JavaScript 源代码。但查看 DOM 并获取您想要获取的内容(图像、视频链接等)并应用您的逻辑很容易。
我希望这有帮助:-)
Actually this kind of bookmarks usually do this:
When you click on Bookmark, then it will run an JavaScript code by redirecting to following URL:
Then SOME_CODE will execute. In this case Pin it button will run following:
Which will end up adding new tag to your document body. Pin It will add "pinmarklet.js" file. Note that "?r=' + Math.random() * 99999999" part is only for get by passing cache from client side by generating new number every time randomly.
If you want to find out exactly what happened next, then you need to take a look at their JavaScript source code. But it's easy to look into DOM and grab what ever you want to grab (Images, Video Links, ...) and apply your logic.
I hope this helps :-)
我在 javacript 上创建了一个函数,用于与 pinterest 共享自定义图像,传递您想要共享的图像的源。
代码: https://github.com/mustaine/Pinmarklet
我希望它有帮助。
I create a function on javacript to share custom images with pinterest passing the source of the images that you would like to share.
Code: https://github.com/mustaine/Pinmarklet
I hope that it helps.