Comments (5)
@gildas-lormeau #122 fixed it for seleniumbase as well, seleniumbase for some reason expects a new tab to disable to CORS issue(strange but hard to detect)
Will check the CDP implementation if that can be done to remove the existing approach
Thanks a lot for your support.
from educative.io_scraper.
CDP impl is done. closing this issue
from educative.io_scraper.
function injectScriptToHTML(scriptTag, location) {
if (location === "iframe") {
var frames = document.querySelectorAll('frame, iframe');
frames.forEach(frame => {
var frameDocument = frame.contentDocument || frame.contentWindow.document;
var targetElement = frameDocument.body || frameDocument.documentElement;
targetElement.appendChild(scriptTag.cloneNode(true));
subframe = targetElement.querySelector('frame, iframe');
var subframeDocument = subframe.contentDocument || subframe.contentWindow.document;
var subtargetElement = subframeDocument.body || subframeDocument.documentElement;
subtargetElement.appendChild(scriptTag.cloneNode(true));
});
}
document.head.appendChild(scriptTag);
}
function createScriptTagFromURL(url) {
return fetch(url)
.then(response => response.text())
.then(data => {
var scriptElement = document.createElement('script');
scriptElement.type = 'text/javascript';
scriptElement.textContent = data;
return scriptElement;
})
.catch(error => {
console.error('Error loading script:', error);
return null;
});
}
window.__define = window.define;
window.__require = window.require;
window.define = undefined;
window.require = undefined;
var baseurl = 'https://anilabhadatta.github.io/SingleFile/';
var urls = [
'lib/single-file-bootstrap.js',
'lib/single-file-hooks-frames.js',
'lib/single-file-frames.js',
'lib/single-file.js'
];
var fullUrls = urls.map(url => baseurl + url);
for(let i=0; i< fullUrls.length; i++){
createScriptTagFromURL(fullUrls[i])
.then(scriptTag => {
if (scriptTag) {
if(i === 1 || i === 2){
injectScriptToHTML(scriptTag, "iframe")
}
else {
injectScriptToHTML(scriptTag, "")
}
}
});
}
should fix
from educative.io_scraper.
Something similar to the code below (not tested) should work in a more generic way.
function injectScriptToHTML(scriptTag, doc = document) {
var targetElement = doc.body || doc.documentElement;
targetElement.appendChild(scriptTag.cloneNode(true));
var frames = doc.querySelectorAll("frame, iframe");
frames.forEach(frame => {
if (frame.contentDocument) {
injectScriptToHTML(scriptTag, frame.contentDocument);
}
});
}
/// ...
injectScriptToHTML(scriptTag);
/// ...
from educative.io_scraper.
@gildas-lormeau Thank you, the recursive solution fix it.
I will although try to impl the CDP solution
from educative.io_scraper.
Related Issues (20)
- THE CHROME BROWSER DOES NOT WORK HOT 1
- ERROR - StartScraper - start: 20: ExtensionScraper:start: 50: ExtensionScraper:scrapeCourse: 91: ExtensionScraper:scrapeTopic: 152: QuizUtility:downloadQuizFiles: 25: QuizUtility:downloadQuiz: 69: 'explanation' HOT 4
- Error: CourseCollectionsJson and CourseTopicUrlsList Urls are not equal HOT 9
- failure HOT 4
- unable to proceed due to captcha HOT 3
- ERROR CourseCollectionsJson and CourseTopicUrlsList Urls are not equal HOT 4
- Can't get full source code files HOT 9
- Unable to run in Macos Apple silicon HOT 9
- [Feature request] Support category in viewer HOT 7
- I am getting this error HOT 5
- Error: ShowUtility:showCodeSolutions: 59: Message: javascript error: Cannot read properties of null (reading 'click') HOT 3
- Exception when get course has Cloud lab inside HOT 2
- request-html would might be a good and fast alternative for selenium HOT 3
- Cant Run in Linux Server HOT 7
- [Minor Bug] [MacOS] Scraper fails to run if path has space in it HOT 1
- looking for Educative course downloader HOT 1
- Group Downloaded Topics by "Modules" or "Sections" HOT 1
- Reduce Downloaded File Size for PDF HOT 1
- Create one PDF for full course, with Contents HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from educative.io_scraper.