import requests
from fake_useragent import UserAgent
from bs4 import BeautifulSoup
def reptile():
'''爬取4399小游戏'''
url = 'https://www.4399.com/'
headers = {'User-Agent': UserAgent().chrome}
reqe = requests.get(url,headers)
reqe.encoding='gbk'
#with open('tmp.txt', 'w', encoding='utf-8') as f:
#f.write(reqe.text)
bea = BeautifulSoup(reqe.text,'lxml')
infos = bea.select('ul.tm_list.lf_ul>li>a')
for i in infos:
print(i.text)
#infos1 = [i.text for i in infos]
if __name__ == '__main__':
reptile()
4399游戏名称爬取
最新推荐文章于 2025-04-30 18:07:56 发布