I think there are several tools and libraries available for this job. E.g.:
wget --mirror -p --convert-links http://www.example.com wget --mirror -p --convert-links http://www.example.com wget -r -l 1 -Ppath/to/folder --convert-links http://www.example.com/