Extract from <head>, then <body> if necessary