資源簡介
這個版本根據之前的版本進行優化,使用了GUI,使得可以根據自己選擇某一天來查詢機票價格,或者未來90天的價格,可以根據自己輸入的始發地,目的地,日期,然后自動爬取該天全部機票的票價,航班,發機時間,還有可以自動保存到excel里面,同時是用來學習爬取網絡一個好的例子,最主要的是能自動保存到excel里面,文件名字都是根據自己來輸入,很智能化
代碼片段和文件信息
#!/usr/bin/env?python
from?selenium.webdriver.common.by?import?By
from?selenium.webdriver.support.ui?import?WebDriverWait
from?selenium.webdriver.support?import?expected_conditions?as?EC
from?selenium?import?webdriver
import?time
from?datetime?import?datetime
from?dateutil.parser?import?parse
from?bs4?import?BeautifulSoup
import?re
import?win32com.client?as?win32
import?requests
from?tkinter?import?*
headers?=?{
‘User-Agent‘:‘Mozilla/5.0?(Windows?NT?10.0;?WOW64)?AppleWebKit/537.36?(KHTML?like?Gecko)?Chrome/63.0.3239.132?Safari/537.36?QIHU?360SE‘
‘Accept‘:‘text/htmlapplication/xhtml+xmlapplication/xml;q=0.9image/webpimage/apng*/*;q=0.8‘
‘Connection‘:‘keep-alive‘
‘Accept-Encoding‘:‘gzip?deflate?br‘
}
city?=?{
‘上海‘:‘sha‘‘北京‘:‘bjs‘‘廣州‘:‘can‘‘深圳
- 上一篇:Python爬蟲爬取百度百科詞條源碼
- 下一篇:Edmonds算法Python版
評論
共有 條評論