简体   繁体   中英

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...

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

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. 2. Is the ther a way to save each one as an html file, I can again sort though.

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.

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.

Otherwise, you can use jQuery/AJAX instead of a popup:

 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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