This won't work with megashares btw, because of their landing page.
You need to request the page once, store the cookies in a cookiefile, then set the referrer to the URL requesting then request the page again with the cookies collected. Yeah its a pain I know.