Floppy Posted November 16, 2011 Posted November 16, 2011 (edited) Hello, I'm creating a script to login to a Website and visit a page.To make it as fast as possible I made the login part with WinHTTP.au3 - _WinHttpSimpleFormFill function. It's very fast!Once logged in, I need to surf a page of that site but I don't need to see it. In other words, the Website should know that I opened that page. I have 2 options:1) Surfing it with _IENavigate in a hidden window.2) Surfing it using WinHTTPThe problem with Option 1 is that if I don't "connect" _IENavigate to _WinHttpConnect, I am not logged in (I think this is because of the cookies).Question: Is there a way to "connect" _IENavigate to _WinHttpConnect?The problem with Option 2 is that I don't know what to do! Is there a way to let the Website know that I visited a page?I hope you understand everything!!Thank you for help and bye! Edited November 16, 2011 by FSoft
Mat Posted November 16, 2011 Posted November 16, 2011 It will know you visited a page if you sent a HTTP request to that page. As far as the server knows, a simple HTTP request and navigating to a page with a web browser is the same, so unless it uses some strange method of detecting whether you've accessed a page then they should be the same. AutoIt Project Listing
trancexx Posted November 16, 2011 Posted November 16, 2011 When working with WinHttp every connection made within the same session as login was made upon, will share cookies unless specified differently. You will be browsing logged-in. IE or any other app can't use your sessions (hence cookies) because it has its own sessions. It would be like after logging with Chrome browser to expect that when opened the site with Firefox you would be logged on. ♡♡♡ . eMyvnE
Floppy Posted November 17, 2011 Author Posted November 17, 2011 Ok, thank you. Suppose I need to visit www.google.com/search/items/45715 ... I wrote this script #include "WinHttp.au3" $address = "google.com" $open_http = _WinHttpOpen() $connector = _WinHttpConnect($open_http, $address) $request = _WinHttpOpenRequest($connector) _WinHttpSendRequest($request) _WinHttpReceiveResponse($request) Global $chunk, $data If _WinHttpQueryDataAvailable($request) Then While 1 $chunk = _WinHttpReadData($request) If @error Then ExitLoop $data &= $chunk WEnd ConsoleWrite($data) Else MsgBox(48, "Error", "Site is experiencing problems.") EndIf _WinHttpCloseHandle($request) _WinHttpCloseHandle($connector) _WinHttpCloseHandle($open_http) Where should I specify "search/items/45715" to notify the Website?
Mat Posted November 17, 2011 Posted November 17, 2011 Look again at _WinHttpOpenRequest. 3rd paramater is "Object name". AutoIt Project Listing
Floppy Posted November 17, 2011 Author Posted November 17, 2011 This way? #include "WinHttp.au3" $address = "google.com" $open_http = _WinHttpOpen() $connector = _WinHttpConnect($open_http, $address) $request = _WinHttpOpenRequest($connector) _WinHttpSendRequest($request, Default, "search/items/45715") _WinHttpReceiveResponse($request) Global $chunk, $data If _WinHttpQueryDataAvailable($request) Then While 1 $chunk = _WinHttpReadData($request) If @error Then ExitLoop $data &= $chunk WEnd ConsoleWrite($data) Else MsgBox(48, "Error", "Site is experiencing problems.") EndIf _WinHttpCloseHandle($request) _WinHttpCloseHandle($connector) _WinHttpCloseHandle($open_http)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now