【发布时间】:2019-01-04 07:20:54
【问题描述】:
我正在尝试从 Amazon.com 获取产品信息。
我在互联网上搜索了一些代码,我找到了一个。我试图修复代码中的错误,但我坚持使用下面的错误。下面代码的最后一行似乎有问题,因为我收到了这个错误:'NoneType' object is not subscriptable
for asin in asin_array:
item_array=[] #An array to store details of a single product.
amazon_url="https://www.amazon.com/dp/"+asin #The general structure of a url
response = session.get(amazon_url, headers=headers, verify=False) #get the response
item_array.append(response.html.search('a-color-price">${}<')[0]) #Extracting the price
【问题讨论】:
-
将完整的回溯复制粘贴到您的问题中肯定会有所帮助。虽然它看起来像一个索引问题。
response.html.search('a-color-price">${}<')返回None?如果是这样,请对其进行一些验证(即 if 语句或诸如此类)。
标签: python arrays append response amazon