finding keywords within prohtml
in
Contributed Library Questions
•
2 years ago
I been working on a script that takes an rss feed's links and and searches through the data on those link pages. but because prohtml's htmlList.printElements(); returns a void instead of a string. Is there a way to convert this to a string so I can use an if() to find keywords? Or is there a better way to search through the data? I've included my code.
thanks,
- import prohtml.*;
- import net.obxlabs.romefeeder.*; //romefeeder
- import com.sun.syndication.feed.synd.*; //ROME
- Feeder feeder; // the feeder
- int feedRate = 2*200; // rate for displaying posts (in miliseconds)
- int feedLast = 0; // time of the last displayed post
- SyndEntry entry; // feed entry
- HtmlList htmlList;//list for news feed
- void setup() {
- size(600, 200);
- smooth();
- frameRate(30);
- //create and set the font
- PFont font = createFont("bluehigh.ttf", 12, true);
- textAlign(LEFT);
- textFont(font, 24);
- text("Loading...", 10, 10);
- textFont(font, 52);
- //create the feeder
- feeder = new Feeder();
- feeder.verbose = true;
- feeder.sort(Feeder.PUBLISHED_DATE);
- feeder.load("http://rss.time.com/web/time/rss/politics/index.xml");
- feeder.setUpdateInterval(5*60*1000); // milliseconds
- //start updating
- feeder.startUpdate();
- background(0);
- }
- void draw() {
- //overlay with semi-transparent background to create the shadowy effect
- fill(0, 0, 0, 20);
- noStroke();
- rect(0, 0, width, height);
- //if there is another entry in the feeder and
- //we waited long enough since the last displayed entry then
- //display the next entry
- if ((feeder.hasNext()) && (millis()-feedLast >= feedRate)) {
- //get the next entry
- entry = feeder.next();
- println(entry.getTitle());
- println(entry.getLink());
- println(" + " + entry.getPublishedDate() + "\n");
- //update the feed timer
- feedLast = millis();
- htmlList = new HtmlList(entry.getLink());
- htmlList.printElements();
- }
- //after search
- //draw the entry title on screen
- fill(250, int(random(190, 220)), 13, 150);
- stroke(62, 54, 21);
- if (entry != null)
- text(entry.getTitle(), 10, 10, width-50, height-20);
- }
1