采集內(nèi)容常需要得到網(wǎng)頁返回的驗(yàn)證碼做進(jìn)一步處理
下面代碼是用python寫的用來獲取網(wǎng)頁http狀態(tài)碼的腳本
#!/usr/bin/python# -*- coding: utf-8 -*-#encoding=utf-8#Filename:states_code.py import urllib2 url = '//m.survivalescaperooms.com/'response = Nonetry: response = urllib2.urlopen(url,timeout=5)except urllib2.URLError as e: if hasattr(e, 'code'): print 'Error code:',e.code elif hasattr(e, 'reason'): print 'Reason:',e.reasonfinally: if response: response.close()
新聞熱點(diǎn)
疑難解答
圖片精選