Jump to content

WinHttp.au3 question on how to download an Amazon product page in HTML

Recommended Posts

Hi everybody.

Can someone help me with WinHttp.au3?

I would like to create a tool which downloads the HTML of a Product page from amazon .  so i can find the current Item selling price.

But i am always getting mixed results.

lets say I want to download the Html for  THIS TOILETTE BRUSH.

with this Function all i get, is the Amazon Homepage where i have to accept some cookies .

#include <WinHttp.au3>

$hSession= _Winhttpopen("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0") ;(user agent)
$sHost="https://www.amazon.de//dp/B00GUJBK4U" ;source
$hHost= _Winhttpconnect($hSession,$sHost); connecting to server



Func _FileWrite($sHTML,$Zusatz="")
    ConsoleWrite($c &"Vote"&$Zusatz&@crlf)
    FileDelete($c &"Vote"&$Zusatz&".html")
    filewrite($c &"Vote"&$Zusatz&".html",$shtml)

so i thought, well maybe this one helps :

#include "Winhttp.au3"
Local $Host = "https://www.amazon.de//dp/B00GUJBK4U"

Local $hOpen = _WinHttpOpen()
Local $hConnect = _WinHttpConnect($hOpen, $Host)
Local $hRequest = _WinHttpOpenRequest($hConnect, "GET", '/', 'HTTP/1.1')
_WinHttpAddRequestHeaders($hRequest, 'Host:https://www.amazon.de//dp/B00GUJBK4U')
_WinHttpAddRequestHeaders($hRequest, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0')
_WinHttpAddRequestHeaders($hRequest, 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
_WinHttpAddRequestHeaders($hRequest, 'Accept-Language:q=0.8,en-us;q=0.5,en;q=0.3')
_WinHttpAddRequestHeaders($hRequest, 'Accept-Encoding: gzip, deflate')
_WinHttpAddRequestHeaders($hRequest, 'Connection: keep-alive')

If (_WinHttpReceiveResponse($hRequest)==1) Then
    Local $Header = _WinHttpQueryHeaders($hRequest)
    Local $Data = _WinHttpSimpleReadData($hRequest, 1)


Func _WriteHtml($Data)
    Local $hFOpen = FileOpen(@ScriptDir &"\hocautoit.html", 2+8+256)
    FileWrite($hFOpen, $Data)
    ShellExecute(@ScriptDir &"\hocautoit.html")

But now  Cloud Front does not like me . and won't let me pass.


If someone has a better Idea on how to get the Item price off from amazon and into Autoit.  Please tell me and spit it here.

Also i have to say. It is my first time trying something with WinHttp. So if someone thinks that this is the wrong way. please let me know.


Thank you :)



Link to comment
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...