#coding=utf-8
from bs4 import BeautifulSoup
import urllib2
import sys
import time
import requests
from PIL import Image
reload(sys)
sys.setdefaultencoding('utf-8')
time=time.localtime()
session=requests.session()
user_agent='Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0'
headers={'User-Agent':user_agent}
cap_url='http://www.jsgsj.gov.cn:58888/mini/netWebServlet.json?randImg=true&tmp='+str(time)
html=session.get(cap_url,headers=headers)
img=html.content
cookies=html.cookies
with open('yanzhenma.jpeg','wb') as imgfile:
imgfile.write(img)
im = Image.open('yanzhenma.jpeg')
im.show()
yzm=raw_input()
url_company='http://www.jsgsj.gov.cn:58888/mini/netWebServlet.json?codeCheck=true&corpName=苏州&yzm='+str(yzm)
html=session.get(url=url_company,headers=headers,cookies=cookies)
page=(html.text)
print page