Web loadStrings

Hi guys

Im working with data extraction of the web. I tried to use examples like the following

String[] rawhtml;
String [] shows;
String html;
int j = 0;
 
void setup(){
  rawhtml = loadStrings("<a href="http://www.bochcenter.org/buy/show-listing" target="_blank" rel="nofollow">http://www.bochcenter.org/buy/show-listing</a>");
  shows = new String[75];
}
 
void draw(){
  for(int i = 0; i < rawhtml.length; i++){
    if(rawhtml[i].indexOf("<div class=\"show-title\">") >= 0){
      shows[j] = rawhtml[i+3];
      j++;
    }
  }
  printArray(shows);
}

But when I compile, I realized that the loadStrings() argument will not work, because of “//” inside, so I don’t know how processing will understand the xml parameters mixed with string letters, or Im wrong in something

Thanks

2 Likes

I don’t think the http:// is nessasary. Just write the link without it.

Also, I don’t think that even the www. is necessary.

Hopefully this helps!

Hello,

An example here:
https://processing.org/reference/loadStrings_.html

This worked:

String[] lines = loadStrings("http://www.bochcenter.org/buy/show-listing");

println("there are " + lines.length + " lines");

for (int i = 0; i < lines.length; i++) 
  {
  println(lines[i]);
  }

:)