所以以前我用youtube数据api v2获得youtube频道订阅者计数.
我使用了以下内容(我使用TED频道进行演示)
http://gdata.youtube.com/feeds/api/users/TEDtalksDirector?alt=json&callback=jQuery111202977260369807482_1433828589506&jsonp&_=1433828589507
Run Code Online (Sandbox Code Playgroud)
但是对于新的v3 api,结果中没有订户数.
https://www.googleapis.com/youtube/v3/subscriptions?part=snippet%2CcontentDetails&channelId=UCAuUUnT6oDeKwE6v1NGQxug&key=fhjfshdjfhsjdhfjshdjfhsjdfhsjdhfjshdjfhsjdhs
Run Code Online (Sandbox Code Playgroud)
有没有办法让我获得订户数量值?
在木偶操作中按Enter键似乎没有任何效果.但是,当我按下其他键时,它会做它应该做的事情.这有效:
await page.press('ArrowLeft');
Run Code Online (Sandbox Code Playgroud)
这不是:
await page.press('Enter');
Run Code Online (Sandbox Code Playgroud)
这是输入的样子:
有任何想法吗?
编辑:我也尝试过page.keyboard.down和page.keyboard.up.
我正在使用这个选择器
$("textarea #myTextArea").val(text);,它不起作用.如果我删除了ID并使用它正在运行的类.为什么jquery不能在这里找到元素?
有没有办法调试puppeteer脚本?由于某种原因,其中一个按钮没有被点击.我已经尝试了所有不同的方式,实际上在另一个脚本中我点击它,但在这一个我没有.
await page.focus('#outer-container > nav > span.right > span.search-notification-wrapper > span > form > input[type="text"]');
await page.type("Some text");
await page.click('#outer-container > nav > span.right > span.search-notification-wrapper > span > form'); // I am clicking on the form because it did work in the other script
Run Code Online (Sandbox Code Playgroud) 我在ElasticSearch中实现了一个自动完成索引,并遇到了排序/评分问题.假设我在索引中有以下字符串:
apple banana coconut donut
apple banana donut durian
apple donut coconut durian
donut banana coconut durian
Run Code Online (Sandbox Code Playgroud)
当我搜索"甜甜圈"时,我希望结果按照术语位置排序,如下所示:
donut banana coconut durian
apple donut coconut durian
apple banana donut durian
apple banana coconut donut
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚如何实现这一目标.术语位置没有考虑到默认评分逻辑中,我找不到在那里获得它的方法.看起来像一个简单的问题,但其他人之前必须遇到这个问题.有人想出来了吗?
谢谢!
我想知道是否有类似于selenium的方式来等待文本出现在特定元素中.我尝试过类似的东西,但它似乎没有等待:
await page.waitForSelector('.count', {visible: true});
情况如下:我fork了用默认浏览器打开一个html文件的过程。以下是我的情况:
if ((pid=fork())==0) {
execlp("/usr/bin/xdg-open", "xdg-open", url, NULL);
/*if execlp failed, exit the child*/
exit(0);
}
Run Code Online (Sandbox Code Playgroud)
但是,我想获取进程的 PID(打开的浏览器),以便稍后也可以关闭它。但我似乎不知道我怎么能得到它。如果您有任何建议,请告诉我。
我试图写总结是有钥匙的所有值一个简单的Python函数喜欢.我正在为这项任务进行函数式编程.因此,我需要使用一个列表理解,map,filter,或reduce.在这种情况下,我认为reduce是一个合理的选择.
def sum_favorites(msgs):
num_favorites = reduce(lambda x, y: x["likes"] + y["likes"], msgs)
return num_favorites
content1 = {"likes": 32, ...}
content2 = {"likes": 8, ...}
content3 = {"likes": 16, ...}
contents = [content1, content2, content3]
print(sum_favorites(contents))
Run Code Online (Sandbox Code Playgroud)
问题出现在我实际运行代码时.我似乎收到了类似的东西:TypeError:'int'对象不可订阅.对我来说,这个错误毫无意义.如果reduce是通过给定的参数真正迭代,然后传递到λ-功能的每个项目应该是一个字典-他们每个人肯定有一个喜欢在他们的关键.问题是什么,这个Python错误究竟是什么意思?
根据https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepresskey-options,您可以模拟用木偶操纵者按下键盘按钮.
这是我做的:
// First, click the search button
await page.click('#outer-container > nav > span.right > span.search-notification-wrapper > span > form > input[type="text"]');
// Focus on the input field
await page.focus('#outer-container > nav > span.right > span.search-notification-wrapper > span > form > input[type="text"]');
// Enter some text into the input field
await page.type("Bla Bla");
// Press Enter to search -> this doesn't work!
await page.press("Enter");
Run Code Online (Sandbox Code Playgroud)
按下按钮不会产生任何结果.它基本上被忽略了.
javascript ×4
node.js ×4
puppeteer ×4
c ×1
dictionary ×1
exec ×1
fork ×1
github ×1
jquery ×1
python ×1
youtube-api ×1