資源簡介
爬取天氣網(wǎng)數(shù)據(jù) 顯示登陸,爬蟲界面并對數(shù)據(jù)進行統(tǒng)計
代碼片段和文件信息
#?-*-?coding:utf-8?-*-
import?requests
import?mysql.connector
from?bs4?import?BeautifulSoup
import?queue?json
import?matplotlib.pyplot?as?plt
import?numpy?as?np
import?time
from?threading?import?Thread
from?pyquery?import?PyQuery?as?pq
import?csv
from?tkinter?import?*
import?tkinter?as?tk
start?=?‘‘
class?TianQiSpider(object):
????def?__init__(self):
????????self.start_url?=?‘http://www.weather.com.cn/textFC/hunan.shtml‘
????????self.headers?=?{
????????????‘User-Agent‘:?‘Mozilla/5.0?(Linux;?Android?8.0.0;?Nexus?6P?Build/OPP3.170518.006)?AppleWebKit/537.36?(KHTML?like?Gecko)?Chrome/70.0.3538.102?Mobile?Safari/537.36‘
????????}
????????#?構(gòu)建隊列,供線程之間傳輸數(shù)據(jù)使用
????????self.url_queue?=?queue.Queue()
????????self.html_queue?=?queue.Queue()
????????self.data_queue?=?qu
評論
共有 條評論