Я пытаюсь перевести this example из google feeds api для работы с Phantomjs. После example из Phantomjs У меня есть следующий:Использовать API Google Feed с помощью Phantomjs
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
// Our callback function, for when a feed is loaded.
function feedLoaded(result) {
if (!result.error) {
// Loop through the feeds, putting the titles onto the page.
// Check out the result object for a list of properties returned in each entry.
// http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
console.log(entry.title);
}
}
}
page.includeJs("http://www.google.com/jsapi?key=AIzaSyA5m1Nc8ws2BbmPRwKu5gFradvD_hgq6G0", function() {
google.load("feeds", "1");
var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");
feed.includeHistoricalEntries(); // tell the API we want to have old entries too
feed.setNumEntries(250); // we want a maximum of 250 entries, if they exist
// Calling load sends the request off. It requires a callback function.
feed.load(feedLoaded);
phantom.exit();
});
Выход говорит:
ReferenceError: Can't find variable: google
Я попытался определением уага Google; сразу после включения, но не повезло. Я новичок в Phantomjs и js в целом. Любые указатели очень ценятся.
Спасибо, что я включил вызов для оценки и удалил обратный вызов, поэтому никакого моста не требуется, но теперь я не получаю никакого вывода из скрипта ... https://gist.github.com/2874110 –
Liking my answer , нет? :) – Detro
вы действительно не ответили на вопрос. Если вы будете ловить рыбу, вам нужно будет сделать лучше. –