I used to do this a lot years back until I came to the realisation of the real problem. The real problem was that I was using this infatuation to a)make myself feel bad and b) as a distraction from my real problems. As long as I was getting all worked up over this person that I barely knew (which in itself was ridiculous when I took a step back and looked at it) then I wasn't focusing on the problems that I was, on a deeper level, afraid to think about. Also I eventually learnt that girls are just ordinary people too, you just have to talk to them.
Not sure if that helps, that's just my story