1. 需要安装requests: pip install requests
2.需要安装ddt : pip install ddt
3.通过Fiddler抓包获取url、headers、cookies等信息
4.python写脚本
# -*-coding:utf-8-*-
import requests
import unittest
import ddt
@ddt.ddt
class testClass(unittest.TestCase):
@ddt.data(('xxx', 'xxx'), ('', ''))
@ddt.unpack
def testGet(self, api_version, station_id):
headers = {
'User - Agent': 'xxx',
'Accept - Language': 'zh - Hans - CN;q = 1',
'Accept - Encoding': 'gzip, deflate',
'Connection': 'keep - alive'
}
cookies = dict(
cookie='XXXX'
)
res = requests.get(
'http:/XXXX',
headers=headers,
cookies=cookies
)
print res.text
print res.status_code
self.assertTrue(u'xxxx' in res.text)
if __name__ == '__main__':
unittest.main()