亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

module 'urllib' has no attribute 'request'

module 'urllib' has no attribute 'request'

慕勒13948 2018-10-06 16:03:45
代碼腳本如下:import urllibimport jsonctrip_header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36','Host': 'flights.ctrip.com','Referer': 'http://flights.ctrip.com/booking/TAO-SJW-day-1.html?DDate1=2017-10-16'}def search_flight(dcity, acity, ddate):request_url = 'http://flights.ctrip.com/domesticsearch/search/SearchFirstRouteFlights?' \+ 'DCity1=' + dcity \+ '&ACity1=' + acity \+ '&SearchType=S' \+ '&DDate1=' + ddaterequest = urllib.request(request_url, headers=ctrip_header)response = urllib.urlopen(request)return_json = response.read()# print return_jsonreturn_data = json.loads(return_json, encoding='gbk')flight_list = return_data['fis']# print flight_listflight_nums = len(flight_list)print('共有航班:', flight_nums, '趟')for i in range(flight_nums):airline = flight_list[i]['alc'] # 航空公司flight_no = flight_list[i]['fn'] # 航班號print('攜程',airline, flight_no),price_list = [each['p'] for each in flight_list[i]['scs'] if each['hotel'] is None] # 非飛宿產品價格print (price_list)if __name__ == '__main__':search_flight('TAO', 'SJW', '2018-10-17')運行時候出現報錯:AttributeError: module 'urllib' has no attribute 'request'求高手指教
查看完整描述
  • 2 回答
  • 0 關注
  • 1801 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號