Could you please explain your situation a littel more detailed?

Can't you simply use the hostname of the domain in your script?

I'm using phpcrawl in a similar way like you, it's running on the same erver as the website that get's crawled, no problems when using the hostname of the website.