简体   繁体   English

从亚马逊的搜索页面请求基于时间的值

[英]Requesting Time Based Values from Amazon's search page

The code I'm using below will return/capture the keyword/phrase suggestions from Amazon's search bar.我在下面使用的代码将从亚马逊的搜索栏中返回/捕获关键字/短语建议。 The problem is that there seems to be time based values in the parameters used to construct the output.问题是用于构造输出的参数中似乎存在基于时间的值。 Can I use a GET request to obtain the current time based values, or is there a better method?我可以使用 GET 请求来获取基于当前时间的值,还是有更好的方法? The code below is used in conjunction with JSonParser to get the suggestions.下面的代码与 JSonParser 结合使用以获取建议。 The result I'm looking for is the output of the code to match the drop down results from the Amazon search bar.我正在寻找的结果是与亚马逊搜索栏下拉结果相匹配的代码输出。

Option Explicit

Public Sub GetTable()

    Dim json As Object, suggestion As Object                '<  VBE > Tools > References > Microsoft Scripting Runtime
    Const SEARCH_TERM As String = "TRAVEL"
    Const SEARCH_TERM2 As String = "BOOKS"
    With CreateObject("MSXML2.XMLHTTP")
        .Open "GET", "https://completion.amazon.com/api/2017/suggestions?session-id=141-0042012-2829544" & _
        "&customer-id=&request-id=7E7YCB7AZZM1HQEZF2G1&page-type=Search&lop=en_US&site-variant=" & _
        "desktop&client-info=amazon-search-ui&mid=ATVPDKIKX0DER&alias=aps&b2b=0&fresh=0&ks=76&" & _
        "prefix=" & SEARCH_TERM & "&event=onKeyPress&limit=11&fb=1&suggestion-type=KEYWORD&suggestion-type=" & _
        "WIDGET&_=1556820864750", False
        .setRequestHeader "User-Agent", "Mozilla/5.0"
        .send
        Set json = JsonConverter.ParseJson(.responseText)("suggestions")
    End With

    For Each suggestion In json
        Debug.Print suggestion("value")
    Next
End Sub

Those params values can be removed except the session-id.除了 session-id 之外,这些 params 值可以被删除。 They are actually cookies values.它们实际上是 cookie 值。 For the session-id you can generate a value for far into the future and that should last for a while.对于 session-id,您可以为将来生成一个值,该值应该持续一段时间。

Option Explicit

Public Sub GetTable()
    Dim json As Object, suggestion As Object, suggestions As Scripting.Dictionary '<  VBE > Tools > References > Microsoft Scripting Runtime
    Const SEARCH_TERM As String = "TRAVEL"
    Const SEARCH_TERM2 As String = "BOOKS"

    Set suggestions = New Scripting.Dictionary
    With CreateObject("MSXML2.XMLHTTP")
        .Open "GET", "https://completion.amazon.com/api/2017/suggestions?session-id=999-5000000-8000000" & _
        "&customer-id=&request-id=&page-type=Search&lop=en_US&site-variant=" & _
        "desktop&client-info=amazon-search-ui&mid=ATVPDKIKX0DER&alias=aps&b2b=0&fresh=0&ks=76&" & _
        "prefix=" & SEARCH_TERM & "&event=onKeyPress&limit=11&fb=1&suggestion-type=KEYWORD&suggestion-type=" & _
        "WIDGET&_=", False
        .setRequestHeader "User-Agent", "Mozilla/5.0"
        .send
        Set json = JsonConverter.ParseJson(.responseText)("suggestions")
    End With
    suggestions(json(1)("widgetItems")(1)("metadata")("text")) = vbNullString
    For Each suggestion In json
        suggestions(suggestion("value")) = vbNullString
    Next
    Dim key As Variant
    For Each key In suggestions.keys
        Debug.Print key
    Next key
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从基于多个条件的亚马逊弹性搜索中搜索数据? - how to search data from amazon elastic search based on multiple conditions? 从亚马逊产品页面获取图像URL - Getting image URL's from amazon product page 从 Rundown API 请求 JSON 时找不到 404 页面 - 404 page not found when requesting JSON from The Rundown API 使用jQuery创建文本输入并根据数组长度和页面加载时的值分配值 - Create text input and assign a value based on array length and it's values on page load using jQuery 如何使用PHP从iTunes Search API JSON页面中提取值? - How do I extract values from the iTunes Search API JSON page with PHP? 显示一个搜索结果页面,其中包含来自php中多维数组的值 - Showing a search results page which has values from a multidimentional array in php 从站点同一文件夹中的外部 json 文件请求数据并在 html 页面 bu jQuery 中使用 - requesting data from exteneral json file in the same folder of the site and use it in html page bu jQuery ROR-从控制器请求JSON - ROR - Requesting JSON from Controller 从Freebase API请求数据 - Requesting data from Freebase API 需要一些信息从亚马逊页面产品 python 3 beautifulsoup 中提取 - Need some information to extract from amazon page product python 3 beautifulsoup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM