View Full Version : Extract text and write to file

02-02-2011, 04:37 PM
Hi, I have an idea for putting news articles on my phone to read later when I have time. I'd like to be able to right-click the text of an article and choose "Send to Phone Queue." When I've got a few articles in the queue, I'd like to be able to bluetooth the file to my phone. I know some HMTL and CSS, but I'm very much a novice when it comes to JavaScript. I'm thinking that I probably can't even do a lot of this with JS because of it's limitations (i.e. writing to a file). Will I need to use PHP or Java for writing/bluetoothing the file? I was playing around with extracting the body-text of an article from FoxNews.com. I didn't get very far but you can see where I'm going with it. I welcome any comments, criticisms, etc. Thanks for anything you say, even shooting this down as unrealistic. :rolleyes: :p :)

function getBodyText() {

var divList = document.getElementsByTagName('div');

for ( i=0; i<=divList.length; i++) {

if (divList[i].getAttribute("class") == "entry-content KonaBody") {

. . .

rnd me
02-02-2011, 04:57 PM
i would use rss feeds for the news: it's a lot more reliable than extracting text from html.

for storing them on your phone, you can make a webpage that uses HTML5 localStorage, in conjunction with offline mode to store and display several hundred articles without internet.
google into yql, jsonp, localStroage, and navigator.onLine.

using yql or another jsonp-based webservice, you can create you entire app with a static html file: no server processing needed.

having it on the web also means you can get to your news articles from anywhere, including phones.

if you try to do it with files and copies and other older data-transfer strategies, it's going to be difficult to work around some of the security precautions present in javascript.