Skip to Main Content
Amazon Hacks
book

Amazon Hacks

by Paul Bausch
August 2003
Intermediate to advanced content levelIntermediate to advanced
304 pages
7h 33m
English
O'Reilly Media, Inc.
Content preview from Amazon Hacks

Program XML/HTTP with VBScript

Accessing Amazon within Windows is a job for VBScript.

VBScript is a common scripting language for the Windows platform. It’s very similar to Visual Basic, and in fact this hack is modified from the example VBA application included with the Amazon developer’s kit. With a few slight modifications, this code could be used in a Word macro, a Visual Basic program, or an ASP web page. In this case, it’s written for Windows Scripting Host, and will run just like any other program.

What You Need

This example requires a Windows machine and the Microsoft XML Parser. If Internet Explorer 4.0 or higher is installed on your machine, the parser is already there.

The Code

Create a text file called amazon_price.vbs with the following code:

' amazon_price.vbs
' This VBScript prompts for an ASIN, and returns the price.
' Usage: double-click amazon_price.vbs, enter ASIN.

Sub AmazonQuery(ASIN_In)
  Dim SelectedText
  Dim MSXML
  Dim XMLURL
  Dim Loaded
    
  ' Make sure that some text is selected
  If ((Len(ASIN_In) = 0) Or (ASIN_In < " ")) Then
    WScript.Echo "Please enter an ASIN."
    Exit Sub
  End If
  
  ' Set Associate ID and Developer Token
  AffiliateTag = "insert associate tag"
  DeveloperToken = "insert developer token" ' Create an instance of the MSXML Parser Set MSXML = CreateObject("MSXML.DOMDocument") ' Set MSXML Options MSXML.Async = False MSXML.preserveWhiteSpace = False MSXML.validateOnParse = True MSXML.resolveExternals = False ' Form the request URL XMLURL = "http://xml.amazon.com/onca/xml3" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

From ChatGPT to HackGPT: Meeting the Cybersecurity Threat of Generative AI

From ChatGPT to HackGPT: Meeting the Cybersecurity Threat of Generative AI

Karen Renaud, Merrill Warkentin, George Westerman
Incident Metrics in SRE

Incident Metrics in SRE

Stepan Davidovic

Publisher Resources

ISBN: 0596005423Supplemental ContentCatalog PageErrata