Sign in to follow this  
Followers 0
CyberGlitch

IE and Cookies

6 posts in this topic

I know autoit can not work with sites that use cookies. Example of what I'm trying to attempt. Want autoit to download a page off of yahoo groups. As an example http://groups.yahoo.com/group/AutoItList/messages Problem comes with that you need to login to view the messages and login is stored in a cookie. I've tried using wget to download the page and the use autoit to do what I need. I could not get wget to download the page reliably either, it did it once but never again. Delete cookies and all files, login save cookie, tried everything and wget only did it once.

Any other ideas or help out there?

Share this post


Link to post
Share on other sites



Ok, figured I'd post back as I got of my lazy but and found a way to use autoit with pages that use cookies.

Use the newer version of wget (1.9 as of this posting) available at http://xoomer.virgilio.it/hherold/

Go the page you want to use and login like normal so your cookies are saved, using IE. Then in IE go to File, Import and Export, Export Cookies and save this file somewhere.

You can this use this file with wget and tell it to use the cookies file. This example assumes wget and the cookies.txt file are in the same directory.

wget.exe --load-cookies cookies.txt http://www.site.com

This will load the cookie file with your login information and then load the site using that cookie. Work great for me now I can code some of the content grabbing scripts I've been wanting to do. Hope this helps some of the others out there trying to do the same.

Share this post


Link to post
Share on other sites

Another way is using the cUrl, which allows you to log on to a web site via script.

Ok, figured I'd post back as I got of my lazy but and found a way to use autoit with pages that use cookies.

Use the newer version of wget (1.9 as of this posting) available at http://xoomer.virgilio.it/hherold/

Go the page you want to use and login like normal so your cookies are saved, using IE. Then in IE go to File, Import and Export, Export Cookies and save this file somewhere.

You can this use this file with wget and tell it to use the cookies file. This example assumes wget and the cookies.txt file are in the same directory.

wget.exe --load-cookies cookies.txt http://www.site.com

This will load the cookie file with your login information and then load the site using that cookie. Work great for me now I can code some of the content grabbing scripts I've been wanting to do. Hope this helps some of the others out there trying to do the same.

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites

I know it's an old post, anyway, for documentation purposes because that page result is on google :D

To save/read cookies you must use $oIE.document.cookies.
That produces a full string separated by ";".

A sample to handle with it (just a google cookies sample):

#include <msgboxConstants.au3>
#include <Array.au3>

Global $oIE = _IECreate("google.es")
Global $oCookie = $oIE.document.cookie
;msgbox($MB_SYSTEMMODAL, "", $oCookies, 10) ; check for string
Global $oCookieValues = StringSplit($oCookie, ";")
_ArrayDisplay($oCookieValues) ; check for Array

So, with that cookies you can reuse using a Global, write to a File, or whatever you need.

The reverse way is to set $oIE.document.cookie = name=value
Didn't try to set all at once using 

$oIE.document.cookie = name1=value1;name2=value2

 but you can play around :D

@zzen11 - cURL is the best ways i'd found to deal with logins/cookies/saving files ever! Never digg too much into wget, but the CLI version of cURL is just easy as that. (curl -c cookie.txt google.es) and -b to save. (http://curl.haxx.se/docs/manpage.html)

Happy AutoITing!


~ SELF SIGNED ~

How much warning points do i need to get my free spicy hammon?

Share this post


Link to post
Share on other sites

"For documentation purposes" You create a new topic and put a reference to this one, you don't necro-post a decade old post even if its the 1st result on Google.

Share this post


Link to post
Share on other sites

 

I know it's an old post, anyway, for documentation purposes because that page result is on google :D

 

Great to understand you know ... so please stop resurrecting old topics unless there is a true purpose and this isn't it!

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0