-
大小: 28.09MB文件類型: .zip金幣: 1下載: 0 次發(fā)布日期: 2023-07-16
- 語(yǔ)言: Python
- 標(biāo)簽:
資源簡(jiǎn)介
基于Python的http流抓取系統(tǒng)
用于查詢IP
用于查詢火車票
用于查詢飛機(jī)票
用于查詢下載播放歌曲
代碼片段和文件信息
#coding=utf-8
import?sys?timereurllib2parsercookielibjsonurllib
‘‘‘Cookies‘‘‘
cookie=cookielib.LWPCookieJar()
chandle=urllib2.HTTPCookieProcessor(cookie)
‘‘‘獲取數(shù)據(jù)‘‘‘
def?getData(url):
????r=urllib2.Request(url)
????opener=urllib2.build_opener(chandle)
????u=opener.open(r)
????data=u.read()
????try:
????????data=data.decode(‘utf-8‘)
????except:
????????data=data.decode(‘gbk‘‘ignore‘)
????return?data
def?postData(urldata):
????data=urllib.urlencode(data)
????data=bytes(data‘utf-8‘)
????r=urllib2.Request(urldata)
????opener=urllib2.build_opener(chandle)
????u=opener.open(r)
????data=u.read()
????try:
????????data=data.decode(‘utf-8‘)
????except:
????????data=data.decode(‘gbk‘‘ignore‘)
????return?data
‘‘‘獲取城市的編碼‘‘‘
def?GetCityCode(offPort):????
????cont=getData(‘http://www.ly.com/Flight/FlightBookAjax.aspx?Type=GetAllCity&callback=tc68544171312‘)
????offPort=‘“‘+offPort+‘“‘
????cont=?cont.split(‘hot‘)
????haveCode=‘‘
????for?x?in?cont:
????????if?offPort?in?x:
????????????haveCode=x
????????????break
????fin=?haveCode.split(‘‘)
????code=‘code‘
????for?y?in?fin:
????????if?code?in?y:
????????????code=y
????????????break
????return?code.split(‘:‘)[1][1:4]
‘‘‘獲取飛機(jī)票信息‘‘‘
class?AirPlane:
????def?init(selfoffPortarrPortdate):
????????self.li=[]
????????offPort_code=GetCityCode(offPort)
????????arrPort_code=GetCityCode(arrPort)
????????url=‘http://www.ly.com/Flight/FlightBookAjax.aspx?Type=QryFlightInfoNew&sort=0&errinner=&TcA=11103084&FilterList=&CabinCode=all&FlightNum=&CompanyCode=all&domain=&plat=&key=B9706D48D6D54250A616559CF3620B26&IsRevisionAfter=fznew&querytype=0&fquerykey=db2ba81e-4260-4fac-b63d-cc93148c78d7&cztype=&IfVip=0&FqdLoginKey=1416582338507554&firstday=%s&isNew=1&offPort=%s&arrPort=%s&date=%s&queryParagraph=1&iid=0.23819635355976443‘?%(dateoffPort_codearrPort_codedate)
????????cont=?getData(url).split(‘“result“:“‘)[1]
????????cont=cont.split(“|“)
????????cont1=[]
????????i=0
????????while?i? ????????????cont1.append(cont[i])
????????????i+=2
????????i=0
????????while?i ????????????tmp=[]
????????????tmp.append(cont1[i].split(‘‘)[3])#起飛時(shí)間
????????????tmp.append(cont1[i].split(‘‘)[5])#到達(dá)時(shí)間
????????????tmp.append(cont1[i].split(‘‘)[1]+cont1[i].split(‘‘)[2])?#航班
????????????tmp.append(cont1[i].split(‘‘)[7]+‘(‘+cont1[i].split(‘‘)[15]+‘)‘)#機(jī)型
????????????tmp.append(cont1[i].split(‘‘)[4])#出發(fā)機(jī)場(chǎng)
????????????tmp.append(cont1[i].split(‘‘)[6])#到達(dá)機(jī)場(chǎng)
????????????tmp.append(cont1[i].split(‘‘)[20])#歷時(shí)
????????????tmp.append(cont1[i].split(‘‘)[16])#估價(jià)
????????????
????????????self.li.append(tmp)
????????????i+=1
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-12-05?21:13??Search_H\
?????文件???????26895??2014-12-02?16:07??Search_H\MainWindow.py
?????文件????????8329??2014-12-01?22:51??Search_H\Pla
?????文件????????9614??2014-12-01?22:52??Search_H\Pla
?????文件???????????0??2014-11-30?23:31??Search_H\__init__.py
?????目錄???????????0??2014-12-02?16:00??Search_H\build\
?????目錄???????????0??2014-12-02?16:00??Search_H\build\bdist.win32\
?????目錄???????????0??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\
?????目錄???????????0??2015-01-12?21:48??Search_H\build\bdist.win32\winexe\bundle-2.7\
?????目錄???????????0??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\
?????文件????????9034??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\Pla
?????目錄???????????0??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\PyQt4\
?????文件?????????549??2014-12-02?17:11??Search_H\build\bdist.win32\winexe\collect-2.7\PyQt4\Qt.pyc
?????文件?????????561??2014-12-02?17:11??Search_H\build\bdist.win32\winexe\collect-2.7\PyQt4\QtCore.pyc
?????文件?????????558??2014-12-02?17:11??Search_H\build\bdist.win32\winexe\collect-2.7\PyQt4\QtGui.pyc
?????文件?????????105??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\PyQt4\__init__.pyc
?????文件?????????561??2014-12-02?17:11??Search_H\build\bdist.win32\winexe\collect-2.7\PyQt4\phonon.pyc
?????文件???????11100??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\StringIO.pyc
?????文件????????7920??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\UserDict.pyc
?????文件????????5442??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\_LWPCookieJar.pyc
?????文件????????4392??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\_MozillaCookieJar.pyc
?????文件????????4172??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\__future__.pyc
?????文件???????22944??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\_abcoll.pyc
?????文件?????????549??2014-12-02?17:11??Search_H\build\bdist.win32\winexe\collect-2.7\_hashlib.pyc
?????文件?????????546??2014-12-02?17:11??Search_H\build\bdist.win32\winexe\collect-2.7\_socket.pyc
?????文件?????????537??2014-12-02?17:11??Search_H\build\bdist.win32\winexe\collect-2.7\_ssl.pyc
?????文件???????14495??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\_strptime.pyc
?????文件????????6424??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\_threading_local.pyc
?????文件????????8718??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\_weakrefset.pyc
?????文件????????5923??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\abc.pyc
?????文件????????2083??2014-12-02?16:00??Search_H\build\bdist.win32\winexe\collect-2.7\atexit.pyc
............此處省略346個(gè)文件信息
評(píng)論
共有 條評(píng)論