Python将json数据发布到AJAX页面

Python将json数据发布到AJAX页面,python,post,python-requests,Python,Post,Python Requests,我正在尝试使用请求模块从网页获取数据。这就是我到目前为止所做的: import requests import sys reload(sys) sys.setdefaultencoding('utf8') params = {'ResetPaging': 'false', 'sortDirection': 'D', 'sortField': 'TransDate',

我正在尝试使用请求模块从网页获取数据。这就是我到目前为止所做的:

import requests

import sys
reload(sys)
sys.setdefaultencoding('utf8')

params = {'ResetPaging': 'false',
                           'sortDirection': 'D',
                           'sortField': 'TransDate',
                           'startRow': 0,
                           'timePeriod': 6,
                           'transactionType': 'purchases'}

url = "http://markets.investorschronicle.co.uk/research/Markets/DirectorDealings"

headers = {"Content-type": "application/x-www-form-urlencoded",
           "Accept": "application/json, text/javascript, */*; q=0.01",
            'Referer': 'http://markets.investorschronicle.co.uk/research/Markets/DirectorDealings',
            'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0',
            'X-Requested-With': 'XMLHttpRequest'
           }

s = requests.Session()

# HEAD requests ask for *just* the headers, which is all you need to grab the
# session cookie
s.head(url)

r = s.post(url, data=params, headers=headers)
print(r.status_code, r.reason)

with open('page1.html', 'w') as f:
    f.write(r.text)
    f.flush()


params['startRow'] = 11 
params['transactionType'] = 'sales'  

r = s.post(url, data=params, headers=headers)
print(r.status_code, r.reason)

with open('sales.html', 'w') as f:
    f.write(r.text)
    f.flush()
主机似乎忽略了我的参数(尽管我从服务器得到了一个200 OK的确认),我只是得到了一个“默认”的购买首页——不管我在帖子中使用了什么参数

我做错了什么