# Web parsing through a Harvey Norman

**URL:** <https://discourse.processing.org/t/web-parsing-through-a-harvey-norman/19638>\
**Category:** Coding Questions\
**Created:** [April 10, 2020, 6:46pm UTC](https://discourse.processing.org/t/web-parsing-through-a-harvey-norman/19638 "2020-04-10T18:46:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Water99](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@Water99](https://discourse.processing.org/u/Water99)\
**Post date:** [April 10, 2020, 6:46pm UTC](https://discourse.processing.org/t/web-parsing-through-a-harvey-norman/19638/1 "2020-04-10T18:46:33Z")

</div>

Hello everyone, so I am pretty young and just getting into processing 2 years ago. I am doing this competition where I am planning to do some web scraping/parsing through Harvey Norman’s website. The project needs to be about PCs so I’m going to parse monitors. I have looked at Danny Shiffman’s video but still a bit confused trying to get it to work. This is bascially Daniel’s work with my poor attempt at what to do.

Thanks,  
Water 🙂

```auto
String runningtime;
PImage poster;

void setup() {
  size(300, 350);
  loadData();
}

void draw() {
  // Display all the stuff I want to display
  background(255);
  //image(poster, 10, 10, 164, 250);
  fill(0);
  text("Shaun the Sheep", 10, 300);
  text(runningtime, 10, 320);
}

void loadData() {
  String url = "https://www.harveynorman.com.au/acer-et322qr-31-5-curved-flat-panel-monitor.html";

  // Get the raw HTML source into an array of strings (each line is one element in the array).
  // The next step is to turn array into one long string with join().
  String[] lines = loadStrings(url);
  String html = join(lines, "");

  String start = "\"final_price\":";
  String end = ",\"hide_price\":";
  runningtime = giveMeTextBetween(html, start, end);//Searching for running time.

  start = "";
  // Search for the URL of the poster image.
  String imgUrl = giveMeTextBetween(html, start, end);
  // Now, load that image!
  poster = loadImage(imgUrl);
  print("s");
}

String giveMeTextBetween(String s, String before, String after) {
before = "\"final_price\":";
after = ",\"hide_price\":";
  // This function returns a substring between two substrings (before and after).
  // If it can’t find anything it returns an empty string.
  //String found = "";

  // Find the index of before
  int start = s.indexOf("\"final_price\":");     
  if (start == -1) {
    return "";
  }    

  // Move to the end of the beginning tag
  // and find the index of the "after" String      
  start += before.length();    
  int end = s.indexOf(",\"hide_price\":", start); 
  if (end == -1) {
    return "";
  }

  // Return the text in between
  return s.substring(start, end);
}

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 14, 2020, 7:47pm UTC](https://discourse.processing.org/t/web-parsing-through-a-harvey-norman/19638/2 "2020-04-14T19:47:10Z")

</div>

Hello,

I had some issues with that site and it wanted me to confirm that I am not a robot.  
So tried something different… for us humans.

Here is a small working example:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2a8b55b28f300a48c1eb15253d2c2464dea9b213.png)

> **Resources**
>
> I encourage you to review the resources available here:
> 
> - The Processing website has references, examples, tutorials, etc.  
> [https://processing.org/](https://processing.org/)
> - Those available with the Processing PDE (IDE).  
> An exploration of the tabs will reveal what is available; there are libraries and examples there.
> - The Coding Train  
> [https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1\_aw](https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw)  
> [https://thecodingtrain.com/](https://thecodingtrain.com/)
> - Happy Coding  
> [Processing Tutorials - Happy Coding](https://happycoding.io/tutorials/processing/)
> - The Processing Foundation  
> [https://processingfoundation.org/](https://processingfoundation.org/)  
> Check out the tabs.  
> In the education tab, there is a reference to the Coding Train.

`:)`

---

<div class="post-metadata">

**Author:** ![Water99](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@Water99](https://discourse.processing.org/u/Water99)\
**Post date:** [April 15, 2020, 3:42am UTC](https://discourse.processing.org/t/web-parsing-through-a-harvey-norman/19638/3 "2020-04-15T03:42:23Z")

</div>

Thanks dude ill defo try that
