【问题标题】:How to get the API link that contains the bestseller badges by python?如何通过python获取包含畅销书徽章的API链接?
【发布时间】:2021-02-18 01:54:49
【问题描述】:

我的任务是在此链接https://www.real.de/item/search/?search_value=lattenrost&valueKey_search_value= 中获取畅销书徽章的数据。 我试图在 Web 开发人员工具(XHR 选项卡)中找到 API 链接,但仍然没有找到它。 你知道我在哪里可以获取链接或获取数据吗?

【问题讨论】:

    标签: python api scrapy web-crawler badge


    【解决方案1】:

    这些都内置在页面源代码中。 请参阅脚本标记中的 hm.initialSearchData 变量。


    使用正则表达式提取您需要的数据。

    import re
    import json
    
    resp = your response text
    
    json_text = re.findall('hm.initialSearchData = (.+?)</script>', resp)
    data = json.loads(json_text[0])
    

    【讨论】:

      猜你喜欢
      • 2023-03-15
      • 2011-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 2015-12-25
      • 1970-01-01
      相关资源
      最近更新 更多