python 爬取网站,没有正确的返回值?
 #coding=utf-8

import sys
import time
import requests
#from lxml import etree
from PIL import Image
reload(sys)
sys.setdefaultencoding('utf-8')
time=int(time.time())

session=requests.session()
user_agent='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36'
headers={'User-Agent':user_agent,'Host':'218.22.14.70:8088'}
#cookies={'JSESSIONID':'23323B4638EBB7CF3D0272A51AC5A7C3', 'clientlanguage':'zh_CN'}
#start_url='http://218.22.14.70:8088/SMEDS/repository.jspx'
#html=session.get(start_url,headers=headers)
captchaUrl='http://218.22.14.70:8088/SMEDS/validateCode.jspx?type=1&id='+str(time)
print captchaUrl
html1=session.get(captchaUrl,headers=headers)
captcha=html1.content
print type(captcha)
with open('captcha.jpg', "wb") as output:
           output.write(captcha)
Image.open('captcha.jpg').show()
captcha = raw_input("enter captcha:")
url1='http://218.22.14.70:8088/SMEDS/repository.jspx?checkNo=40&searchType=CX&entName=安徽&pageNo=&textfield2='
html1=session.get(url1,headers=headers,cookies=html1.cookies)
info=(html1.content)
print type(info),info
print html1.headers

没有查询结果,求解。。。

1个回答

g=utf-8

import sys
import time
import requests
#from lxml import etree
from PIL import Image
reload(sys)
sys.setdefaultencoding('utf-8')
time=int(time.time())

session=requests.session()
user_agent='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36'
headers={'User-Agent':user_agent,'Host':'218.22.14.70:8088'}
#cookies={'JSESSIONID':'23323B4638EBB7CF3D0272A51AC5A7C3', 'clientlanguage':'zh_CN'}
#start_url='http://218.22.14.70:8088/SMEDS/repository.jspx'
#html=session.get(start_url,headers=headers)
captchaUrl='http://218.22.14.70:8088/SMEDS/validateCode.jspx?type=1&id='+str(time)
print captchaUrl
html1=session.get(captchaUrl,headers=headers)
captcha=html1.content
print type(captcha)
with open('captcha.jpg', "wb") as output:
output.write(captcha)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问