簡體   English   中英

從多個JavaScript觸發的iframe彈出窗口中保存數據(抓取網站)

[英]Save Data from multiple javascript triggered Iframe popups (scrape site)

我需要保存一堆用JS觸發的彈出窗口中的數據,以從服務器檢索數據並在iframe彈出窗口中顯示該數據,單擊每個鏈接並復制數據將永遠花費...

我需要一種方法來抓取可以排序的數據

鏈接

<a href="javascript:getReport('111')">LINK</a>
<a href="javascript:getReport('112')">LINK2</a>

JS

function getReport(ID) {
var id = ID;
var modalType = 'user';
parent.parent.$.fn.colorbox({
    href: ReportUrl + '?sharedID=' + id + '&modalType=' + modalType,
    open: true,
    iframe: true,
    width: 700,
    height: 400,
    title: 'report',
    close: "<button id=\"Close\" onClick=\"javascript:parent.parent.$.fn.colorbox.close()\">Close</button>",
    onClosed: false
});

}

我的想法1.是否有一種方法可以觸發它們全部打開,復制所有數據然后對其進行排序。 2.是將每個文件另存為html文件的一種方法,不過我可以再次排序。

一旦我可以在本地訪問數據,就可以毫無問題地對它進行排序,這只是如何獲取數據的問題,我四處張望,但看不到任何刮取數據的方法,想要抓取的不在設置的URL上,則需要導航JS鏈接,然后打開html頁面。

如果有人有任何建議,我將非常感激。

如果您要抓取的URL與包含“抓取器”代碼的頁面不在同一個域中,則由於跨域安全性而無法使用。

否則,您可以使用jQuery / AJAX而不是彈出窗口:

 jQuery.ajax({ url: ReportUrl + '?sharedID=' + id + '&modalType=' + modalType, method: 'GET', success: function(res) { console.log(res.responseText); // res.responseText is the content from the response, typically HTML source code }, error: function() { console.warn('Something happened'); } }); 

同樣,這適用於同一域。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM