I want to retrieve the text within a webpage as a string. Is this possible? I am new to Javascript.
For example:
var url = "http://en.wikipedia.org/wiki/Programming";
var result = url.getText(); <---- stores text as a string
document.write(result);
How do I write the getText method? Ether the entire HTML source code (which I can use to get the text) or just the text. I would like to do this from within a web browser.
I tried this and I am able to get an index number:
var url = "http://www.youtube.com/results?search_query=cat&page=2";
var result;
function go(){
result = url.search(/cat/i);
document.write(result);
}
This gives me an index of 44. That means that reading a page is possible. Can I do the opposite and enter the index to retrieve the text?