2015-09-14 60 views
0

我試圖使用發送GET請求的python請求。但是,我發現由request.get()形成的url不遵循該文檔。python request.get不會構成正確的URL

下面是一個例子:

import requests 

root_web_address = 'http://www.amazon.com' 
action_address = '/s/ref=nb_sb_noss' 

get_url = root_web_address + action_address 

input_1_value_unicode = unicode('search-alias=aps', 'utf-8') 
input_2_value_unicode = unicode('asics', 'utf-8') 

get_parameters = {'url':input_1_value_unicode, 'field-keywords':input_2_value_unicode} 

r = requests.get(get_url, params = get_parameters) 

print r.url 

預期的URL應該是:

http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=asics 

但是,打印r.url給我:

http://www.amazon.com/s?ie=UTF8&page=1&rh=i%3Aaps%2Ck%3Aasics 

爲什麼?

+0

難道我的回答幫助? –

+0

謝謝,它有幫助! –

回答