I am writing a module to catalog films, and am struggling with the drupal API to figure out the best way to achieve what I want.

I have managed to write a form with the fields I want (lets say 'title', 'director', 'genre', 'year', etc).

Ideally I would like to fill in one field, say 'url' and a button 'lookup', and then with some logic I write, go off and populate the fields with information scraped from the retrieved page located at the address indicated by 'url'. (i'm using the parsing_api module).

So I guess my question boils down to this (assume my module is called 'test1':
in the function test1_form(&$form_state), I have added all the field information, what is a good way of taking one fields contents upon clicking of a button, and then going off, and after having applied logic to retrieve values, populate the form fields with these values?

I have seen it's possible to pre-populate form fields with information in the URL, but this seems messy. Should I be looking at $form_state as a means of returning back to the form after I have submitted the form the first time round, in order to get the URL and apply my logic over it to generate the other field values for the form? If so, how can I do this and if not, what's a recomendation? I guess this might work kind of like preview?

Or at least, any direction to point me to, where I can perhaps find out the relevent bits?

Thanks