I am trying to make a function that would connect to a site and read the source code and return the description and the title of the page.

Example:

let say this is our function: get_description ($url)Then, calling get_description ("http://www.excite.com") should return the following text:
"Excite is the leading personalization Web portal, featuring world-class search, content and functionality. From financial portfolios to sports scores, local weather forecasts to movie listings, Excite gathers what matters most to you every day. It's like your very own online personal assitant."

It's kind of working but very weakly: I am not concerned too much with the data or how to filter it... but my main problem is handling sites that redirect you to others. I will be using this code with "jump" pages mainly.

That would really depend on how the sites are redirecting you. You see a webpage is just text, formatted to HTML standards, and available at a specific URL. This is how you access and read it. Your browser reads the text, and interprets the HTML commands (tags etc) and displays it accordingly.

If the sites are controlling the 'headers' to redirect you, you can't do much since there was never a page there to begin with. But if they're using javascript or meta-refresh tags, then this shouldn't be a problem because these are only actioned by your browser.