通过代理发送请求不起作用

时间:2016-12-13 11:36:41

标签: python python-3.x python-requests python-3.5 http-proxy

我需要在python中使用http发送requests请求。代理需要在美国,所以我得到美国货币。 到目前为止,我做到了这一点:

import requests
proxies = {'httpс': 'httpс://97.77.104.22:3128'}

response = requests.get("https://www.ncl.com/ca/en/search_vacations?cruise=1&cruiseTour=1&cruiseHotel=1&cruiseHotelAir=1&flyCruise=1&numberOfGuests=4294953449&state=undefined&pageSize=10&currentPage=", proxies=proxies)
cruise_results = response.json()
for line in cruise_results['results']:
    print(line)

尝试了几种不同的IP /端口组合,但我仍然得到欧元价格。我做错了吗?

1 个答案:

答案 0 :(得分:1)

proxies dictionary应该有httphttps个键。 httpc

import requests
proxies = {'https': 'httpс://97.77.104.22:3128'}

response = requests.get("https://www.ncl.com/ca/en/search_vacations?cruise=1&cruiseTour=1&cruiseHotel=1&cruiseHotelAir=1&flyCruise=1&numberOfGuests=4294953449&state=undefined&pageSize=10&currentPage=", proxies=proxies)
相关问题