简体   繁体   English

从多个JavaScript触发的iframe弹出窗口中保存数据(抓取网站)

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

I need to save the data from a bunch of popup windows that are triggered with JS to retrieve the data fro the server and display that data in an iframe popup, clicking each link and copying the data will take forever... 我需要保存一堆用JS触发的弹出窗口中的数据,以从服务器检索数据并在iframe弹出窗口中显示该数据,单击每个链接并复制数据将永远花费...

I need a way to scrape the data that I can then sort 我需要一种方法来抓取可以排序的数据

The links 链接

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

The JS 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
});

} }

My thoughts 1. is there a way to trigger them all open, copy all the data then sort it. 我的想法1.是否有一种方法可以触发它们全部打开,复制所有数据然后对其进行排序。 2. Is the ther a way to save each one as an html file, I can again sort though. 2.是将每个文件另存为html文件的一种方法,不过我可以再次排序。

Once I have the data accessible locally I can sort it with out much of an issue, its just a matter of how I can get the data, I have looked around but don't see any way of scraping the data, Since the page I want to scrape isn't on a set url, you need to navigate JS links that then bring up the html page, This is also all behind a login. 一旦我可以在本地访问数据,就可以毫无问题地对它进行排序,这只是如何获取数据的问题,我四处张望,但看不到任何刮取数据的方法,想要抓取的不在设置的URL上,则需要导航JS链接,然后打开html页面。

If anyone has any suggestions I would be really greatful. 如果有人有任何建议,我将非常感激。

If the URLs you're trying to scrape don't exist in the same domain as the page containing the "scraper" code, it won't work due to cross-domain security. 如果您要抓取的URL与包含“抓取器”代码的页面不在同一个域中,则由于跨域安全性而无法使用。

Otherwise, you can use jQuery/AJAX instead of a popup: 否则,您可以使用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'); } }); 

Again, this will only work on the same domain. 同样,这适用于同一域。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM