[Newbies] RE: classes and code snippets to download a web page

Levente Uzonyi leves at elte.hu
Sun May 26 04:41:54 UTC 2013


On Sat, 25 May 2013, Joseph J Alotta wrote:

> I cannot find the WebClient class.  There needs to be a way to insert login information.
>
> Remember you are talking with a beginner here.
>
> Can someone please post a working snippet of code?

To install WebClient:

Installer ss
 	project: 'WebClient';
 	install: 'WebClient-Core'.

To fetch something (username and password will be asked if and 
when needed):

response := WebClient httpGet: 'http://example.com'.

If you want to specify the username and password beforehand and have no 
interaction (no asking for username/passord if the specified ones are 
incorrect):

client := WebClient new.
client authParams: (Dictionary new
 	at: #username put: 'your username here';
 	at: #password put: 'your password here';
 	yourself).
response := client httpGet: 'http://example.com'.

In both cases 'response' will be a WebResponse object. You can check if 
your request was successful:

response isSuccess.

or get the response code:

response code.

or get the content of the response (if it exists):

response content.


Levente

>
>
> Sincerely,
>
> Joe.
>
>
>
>> Greetings,
>>
>> I am looking for classes and code snippets to download a statement from my mutual fund company.
>>
>> It would have to login, submit the password and then download from a link.
>>
>> Does anyone have code that does this?
>>
>>
>> Sincerely,
>>
>> Joe.
>>
>>
>> Hi Joe,
>>
>>
>>
>> Have a look at WebClient httpGet:
>> 'http://yourAddress.com/yourLinkToDownload'
>>
>>
>>
>> It handles everything you need.
>>
>>
>>
>> All the best,
>>
>>
>>
>> Ron Teitelbaum
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>


More information about the Beginners mailing list