My domain:
<!DOCTYPE html>
<html>
<head>
<title>scrape</title>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
</head>
<body>
<script>
$.ajax({url:'http://their-domain.com/index.html',
dataType:'html',
success:function(data){console.log(data);}
});
</script>
</body>
</html>
What prevents me from being able to scrape their-domain? Any work around?
Addendum: thank you all for the suggestions to use a server side script, but I am for the moment interested in solving this problem exclusively using the client.
If I format the request using "jsonp" I do at least get a response, but with the following error:"Uncaught SyntaxError: Unexpected token <". So I am getting a response from their-domain but the parser expects it to be json. (As well it should.) I am hacking through this trying to see if their is a way to trick the client into accepting this response. Please understand that I know this is atypical.
<!DOCTYPE html>
<html>
<head>
<title>scrape</title>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
</head>
<body>
<script>
$.ajax({url:'http://their-domain.com/index.html',
dataType:'jsonp',
success:function(data){console.log(data);}
});
</script>
</body>
</html>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…