You can easily simulate user input. You can submit form on the web page from you program by sending post\get request to a website.
Typical login form looks like:
<form name="loginForm" method="post" Action="target_page.html">
<input type="Text" name="Username">
<input type="Password" name="Password">
</form>
You can send a post request to the website providing values for Username & Password fields. What happens after you send your request is largely depends on a website, usually you will be redirected to some page. You authorization info will be stored in the sessions\cookie. So if you scrape client can maintain web session\understands cookies you will be able to access protected pages.
It's not clear from your question what language\framework you're going to use. For example there is a framework for screen scraping (including login functionality) written in perl - WWW::Mechanize
Note, that you can face some problems if site you're trying to login to uses java scripts or some kind of CAPTCHA.