python MAC地址查询
生活随笔
收集整理的這篇文章主要介紹了
python MAC地址查询
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?使用公網(wǎng)的查詢網(wǎng)頁抓爬方式
from bs4 import BeautifulSoup import requestsmac="88-46-04-46-75-34" url="https://mac.bmcx.com/%s__mac/" % mac html=requests.get(url,verify=False).content html=html.decode('utf-8') html=BeautifulSoup(html,features="html.parser") tr=html.select("#main_content table td table tr") for row in tr:if "組織名稱" in row.text:td=row.select("td")print(td[1].text)使用MAC字典
字典下載地址:https://standards-oui.ieee.org/
import re mac={} f=open("../mac.txt",mode='r',encoding='utf-8') stream=f.read() pattern="(\S+)\s+\(hex\)\s+([^\n]+)" pattern=re.compile(pattern) search=pattern.findall(stream) for s in search:mac[s[0]]=s[1]def get(m):m=m[:8]if m in mac.keys():return mac[m]else:return "未知"總結(jié)
以上是生活随笔為你收集整理的python MAC地址查询的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: gridview添加header
- 下一篇: Scheme N皇后