0
Attain text from external site using javascript
External site: https://flow.c1.biz/Home/urls.txt I am on https://flow.c1.biz/Home/index.html How can I get all text from the external site using javascript without having to open it?
1 Resposta
+ 1
If you are running the code on a browser console, you will not be able to access local files on your computer, this is built into the browsers for security reasons. To solve this use node.js on your local machine, this allows you to run javascript files from the terminal
Edit: I know this is not exactly what you are looking for, but is a clever workaround:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="file" id="input">
<p id="output"></p>
<script>
document.getElementById('input').addEventListener('change', function() {
let fr = new FileReader()
fr.onload = ()=>{
document.getElementById("output").textContent = fr.result
}
fr.readAsText(this.files[0])
})
</script>
</body>
</html>