惠州市网上挂牌交易系统

惠州市网上挂牌交易系统 为例

http://www.hdgtjy.com/index/Index4/

采集所有的挂牌交易信息

源码

import urllib2
import json

fp = open('hdgtjy.json','w')
for page in range(1,28):

    for i in range(5):
        try:
            send_headers = {'X-Requested-With': 'XMLHttpRequest', 'Content-Type': 'application/x-www-form-urlencoded'}

            request =urllib2.Request('http://www.hdgtjy.com/Index/PublicResults',data='page='+ str(page) +'&size=10',headers=send_headers)
            response = urllib2.urlopen(request)
            data = response.read()
            obj =  json.loads(data)
            print obj['data'][0]['ADDRESS']

        except Exception,e:
            print e
    fp.write(data)
fp.close()
print 'end'

查看运行结果,感受一下。