Bug in my code where any freeflowing text within the html would be captured by the html parser and sent to the requesturl function. I have added the check at the start where it determines if input data is an html file or not based on a regex match.