谢谢你抽出时间来帮助我。我正在用django编写一个网络刮削api,但在过去的5天里,我一直得到一个可怕的错误!奇怪的是,在macOS上完全没有错误,当我部署到AWS时,它向我抛出了变量引用错误!ubuntu的python 3.6.8和macOS的python 3.6.6
我已经尝试了不同的方法,但现在我想不出任何方法!在macOS上应该返回的搜刮数据返回得很好,但在ubuntu上,我得到了粉碎!请帮助!"。
data_list = []
div_class = scrape_driver_2.find(class_ = 'c1_t2i')
daraz_products = scrape_driver.find_all(class_ = 'c2prKC')
for data_fragment in daraz_products: # iterate and find all classes
data_block = data_fragment.text.strip() # Convert code to text
formatted_block = data_block.replace('ADD TO CART', '')
second_iterated_block = formatted_block.replace('%', '')
third_iterated_block = second_iterated_block.replace(')Pakistan', ')-Pakistan')
fourth_iterated_block = third_iterated_block.replace('Pakistan', '-Pakistan')
data_list.append(fourth_iterated_block)
high_data = [{"Timestamp": time_stamp,
"TS Token": ts_token,
"Status": sitrep},
data_list]
return Response({"data": high_data})
engine_initializer.close()
我得到的错误是:
UnboundLocalError at /api/big-budget-filter/(未绑定的本地错误)。
本地变量'high_data'在赋值前被引用