def 爬取4399():
??? #發送請求并且拿到源代碼
??? import requests
??? 鏈接='https://www.4399.com/' #網站鏈接
??? 請求頭={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0'} #構造請求頭用于爬取網站源代碼使用
??? 網站源代碼=requests.get(url=鏈接,headers=請求頭).text? #發送請求并且拿到網站源代碼
?? ?
??? #解析數據
??? from bs4 import BeautifulSoup
??? 初始化=BeautifulSoup(網站源代碼,'lxml') #初始化
??? class屬性的結果=初始化.find(class_="tm_list") #class是關鍵字
??? li標簽內容=class屬性的結果.find_all('li') #list
??? for i in li標簽內容:
??????? tex=i.text
??????? Fun.AddRowText(uiName,'ListView_1',rowIndex='end',values=tex)
?????? ?