Python - 初級爬蟲實驗1
今天實驗試作一個爬蟲。 抓Yahoo首頁查特定文字出現次數... 執行環境Jupyter Notebook。 # [Source code] get_ipython().run_line_magic('matplotlib', 'inline') import numpy as np import matplotlib.pyplot as plt from matplotlib import font_manager import requests import re #正則表達式 # 設定中文字型否則圖無法正常顯示中文字 myfont = font_manager.FontProperties(fname='mingliu.ttc') searchUrl = 'http://tw.yahoo.com/' htmlfile = requests.get(searchUrl) name = np.array(["柯文哲","蔡英文","郭台銘","韓國瑜","館長"]) timeValue = [0,0,0,0,0]