0

我制作了自定义共享按钮,并想为它们添加Pocket count。

如果您在浏览器中打开此链接https://widgets.getpocket.com/v1/button?count=vertical&url=http://google.com,您将看到带有计数器的 Pocket 按钮(例如,URL 是 google .com)。

这是一个简单的html文档:

<html><head>
<link rel="stylesheet" type="text/css" href="https://d7x5nblzs94me.cloudfront.net/v1/c/button.css?v=6">
<script type="text/javascript" src="https://d7x5nblzs94me.cloudfront.net/v1/j/shared.js?v=2"></script>
<style type="text/css"></style></head>
<body>

<div class="widget vertical pocket center">
    <a id="btn">
                <!-- 
        Please do not scrape this for the Pocket count. 
        It is not relible for you to use and will likely change. 
        Contact us at api@getpocket.com for an official API. 
        Thanks! 
        -->
        <span><em id="cnt">126775</em><i></i><u></u></span>
                <b></b>
    </a>
</div>

<script type="text/javascript">
var POCKET_DOMAIN = 'getpocket.com';
var iLi = true;

var btnData = {"mode":"viapocketbutton","ct":"b607befed1e75f78567281514cae33db78cbcab9","ctn":"ed82217ee621d17ee56ca091cd836e96149b7921","label":"pocket","count":"vertical","src":"","url":"http:\/\/google.com"};
</script>
<script type="text/javascript" src="https://d7x5nblzs94me.cloudfront.net/v1/j/button.js?v=5"></script>

</body></html>

<em id="cnt">...</em>如何用jQuery.ajax()其他东西(js)解析这个Pocket count(放在)?

4

1 回答 1

0

原谅我,我在手机上。您应该能够使用 jQuery 的“load()”函数发出 GET 请求。

该函数接受一个 url 和回调,一旦请求处理完毕,它将从口袋中返回 html:

$.load(myURL, function(data){
    var dom = $(data).html()
    var pocket = dom.find('pocket selector')
});

一旦您可以访问“dom”,查询按钮然后使用“text()”来获取它可能就是 ID 走的路线!

于 2015-09-25T01:09:17.087 回答