Changeset 11287
- Timestamp:
- 05/09/08 04:22:04 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/jsAutoPageScraper/trunk/js/jsAutoPageScraper.js
r9590 r11287 1 1 /** 2 * jsAutoPageScraper 0. 22 * jsAutoPageScraper 0.3 3 3 * 4 4 * (c) mashmatrix, inc. … … 52 52 */ 53 53 function createIframe(url, callback, scope) { 54 // ugly W/A to prevent cache...55 if (url == window.location.href) {56 url += url.indexOf('?') >= 0 ? '&' : '?';57 }58 54 var iframeEl = windoc.createElement('iframe'); 59 55 iframeEl.style.width = iframeEl.style.height = 0; 60 56 iframeEl.style.visibility = 'hidden'; 61 57 iframeEl.style.position = 'absolute'; 62 iframeEl.src = url; 58 iframeEl.src = "about:blank"; 59 60 getBodyEl().appendChild(iframeEl); 63 61 64 62 addEvent(iframeEl, 'load', function() { … … 67 65 }); 68 66 69 getBodyEl().appendChild(iframeEl);67 iframeEl.contentWindow.location.href = url; 70 68 71 69 } … … 100 98 var scriptEl = doc.createElement('script'); 101 99 scriptEl.type = 'text/javascript'; 102 scriptEl.src = xpathLibUrl ;100 scriptEl.src = xpathLibUrl + '?useNative=false'; 103 101 doc.documentElement.appendChild(scriptEl); 104 102 pollXPathLibLoadStatus(); … … 198 196 .skip(5) 199 197 .scrape(10, callback2) 200 . wait();198 .force(); 201 199 202 200 function callback1(records) { ... } … … 269 267 270 268 /** 271 * Refresh queued commands and wait next command by keeping current cursor and resources.269 * Wait next command by keeping current cursor and resources. 272 270 * 271 * @param {Number} msec - msec to wait for next fetch (optional) 273 272 * @returns Self instance 274 273 * @type JSAutoPageScraper 275 274 */ 276 wait : function() { 277 this.force(); 275 wait : function(msec) { 276 var _this = this; 277 if (msec) { 278 var cmd = { 279 method : 'wait', 280 args : [ msec, function() { _this.force() } ] 281 } 282 this.cmdQueue.push(cmd); 283 } 278 284 return this; 279 285 } … … 347 353 348 354 /** 355 * Wait scraping 356 * 357 * @param {Number} msec - Waiting time (in milliseconds) 358 * @param {Function} callback - Callbacked when timeouted. 359 */ 360 wait : function(msec, callback) { 361 window.setTimeout(callback, msec); 362 } 363 , 364 365 /** 349 366 * Clear and reset fetching states. 350 367 */ … … 394 411 } else if (this.paragraphs.length == 0) { 395 412 delete this.paragraphs; 396 this.nextUrl = queryXPathElement(this.doc, this.siteinfo.nextLink); 413 var nextLink = queryXPathElement(this.doc, this.siteinfo.nextLink); 414 this.currUrl = nextLink && nextLink.href; 397 415 this.cleanupIframe(); 398 if (!this. nextUrl) {416 if (!this.currUrl) { 399 417 this.onFinish(); 400 418 } else {
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)