Optimising repetitive code

Section 3:

//WEATHER STUFF

void connectAndRead(){
  //connect to the server
  if (wifly.isConnected()) {
    wifly.close();
  }
  //RN-XV GET request
  if (wifly.open(site, 80)) {
    wifly.println("GET http://weather.yahooapis.com/forecastrss?w=26376587 HTTP/1.0");
    wifly.println();

    //Connected - Read the page
    char inString[7];
    inString[6] = '\0';
    byte charCount = 0;
    boolean recordOn = false;
    
    //While weather code prefix 'code="' not reached
    while(strcmp(inString,"code=\"") != 0)
    {
      //Read char from RN-XV
      if(wifiSerial.available())
      {
        char c = wifly.read();
        
        //If first letter of 'code="', start recording
        if(c == 'c')
        {
          recordOn = true;       
        }
        
        //Record for 6 chars
        if((recordOn == true) && (charCount < 6))
        {
          inString[charCount] = c;
          charCount++; 
        }
        //If more than 6 chars, not 'code="', so reset count
        else if((recordOn == true) && (charCount >= 6))
        {
          charCount = 0; 
          for(byte i=0;i<11;i++)
          {
            inString[i] = '\0';
          }
        }

        if(Serial.available())
        {
          wifiSerial.write(Serial.read()); 
        }
      }
    }

    //Rinse and repeat above to pick up weather code - next 1 or 2 digits
    //after 'code="'
    char code[] = "\0\0\0"; // string for incoming serial data
    byte codeCount = 0;
    boolean codeRecordOn = false;

    while(codeCount < 2)
    {
      if(wifiSerial.available())
      {

        char c = wifly.read();

        if(c != '"')
        {
          code[codeCount] = c; 
        }

        if(Serial.available())
        {
          wifiSerial.write(Serial.read()); 
        }
        codeCount++;
      }
    }
    //Set global wCode to retrieved code
    for(byte i=0;i<2;i++)
    {
      wCode[i] = code[i];
    }
  } 
}