Sign in to follow this  
Followers 0
RickB75

WinHttp Send Request Help

8 posts in this topic

Guys,

      I need some help and guidance.  I trying to figure out how to use WinHttpRequest and other functions from Trancexx's WinHttp UDF. I can connect to a page, login and get the first response txt after I login. I'm trying to figure out how to send the request to navaigate to the page I need. I'm sure I need to include data for the header info but this is where I'm getting lost. I don't know what info to include. I'm using Google Chrome's Dev Tool bar and I can see all the data in the Network section that's being sent. I just don't know the info that I need. I'm not asking for any of you guys to write the code, I'm just looking for some guidance. Do I need Cookie info ya think? Right now I'm lost. Unfortunately I can't give you guys login info on the website because it is a cooperate website. If you want me to post example code, I can.

 
 

 

 

Share this post


Link to post
Share on other sites



Here's the weird part I'm running into. Once logged into the site, a pop up will flash on the my screen and then it gets hidden. Basically a redirect. I can read and get the source code for that pop up using WinHttp. I can't navigate to the home page of the site though. I keep getting an error. I've tried diff functions like _WinHttpSimpleSSLRequest and I get a page source back that says this page doesn't exist. I'm trying go to the Home page for testing purposes. 

Share this post


Link to post
Share on other sites

When I log in and I send the request, I keep getting a "The Page requested is not available" returned. Should I use be using a diff URL. If so, where would I find it??  If I don't put any page at all in, I get a "Hi There" response. 

Share this post


Link to post
Share on other sites

I'm sure posting an example of what you are doing will bring help faster for you ;)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Ok... Here's a very similar script to what I'm using on our cooperate site. I'm using the Autoit forum as an example. I haven't tested this yet for this site so I'm not sure if it will actually login or not. Let's pretend we want to log in and go to the user settings page. 

#include "WinHttp.au3"

Global $sDomain = "autoitscript.com"
Global $sPage = "forum/index.php?app=core&module=usercp"

; Initialize and get session handle
Global $hOpen = _WinHttpOpen()

; Get connection handle
Global $hConnect = _WinHttpConnect($hOpen, $sDomain)
 _WinHttpSimpleFormFill($hConnect, "forum", "inline_login_form", "name:ips_username", "myUserName","name:ips_password","myPassword")

; Make a request
Global $hRequest = _WinHttpOpenRequest($hConnect, "GET", $sPage)
_WinHttpAddRequestHeaders($hRequest, "Content-Type: application/x-www-form-urlencoded")




; Send it. Specify additional data to send too. This is required by the Google API:
_WinHttpSendRequest($hRequest)

; Wait for the response
_WinHttpReceiveResponse($hRequest)

; See what's returned
Global $sReturned
If _WinHttpQueryDataAvailable($hRequest) Then ; if there is data
    Do
        $sReturned &= _WinHttpReadData($hRequest)
    Until @error
EndIf

; Close handles
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

; See what's returned
ConsoleWrite($sReturned)
;MsgBox(0, "Returned", $sReturned)

Share this post


Link to post
Share on other sites

 Automating the login to this forum might not be the best example.   While you are not technically bypassing the security measure, logins and captchas are generally off limits as they lead to spam potential, spatential.

There used to be a big "Do Not Automate The Forums"  but i cant seem to locate that now anywhere except in quotes from Valik, so maybe its ok now?


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Guys... I guess this was a bad example. I'm not concerned with the automation of logging in. My question is once I'm logged in to whatever website(gmail, hotmail, ect...), how do I correctly send a request for a page within the site. Thats what my question is. I know the rules about asking for help with auto login scripts and I'm not asking for that. I'm just trying to figure out how to send a proper request. I'm missing something in my main script and I don't know what it is. 

If the moderators feel that this is a auto login script then please lock the thread and I won't ask anymore and I'm sorry to have bothered you guys with this question and I don't mean or want to break any forum rules. 

Edited by RickB75

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

The "guys" probably have no issue, I generally have viewpoints that are all my own. It is apparent what the goal is so dont sweat that, but certainly dont be surprised (nor offended) if scripts directed at the autoit site draw additional scrutiny and are discouraged.

I use the google API for gmail, places, and maps.  hotmail i have no idea.  What "page" are you attempting to navigate to within gmail?  To make automated requests in damn near all their stuff I have to use my API Key.  Your request may also be better met through another means, I use JSON (the JSMN UDF) for all my fetches.

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0