In [ ]:
import requests from bs4 import BeautifulSoup rqq = requests.get('http://www.tipdm.com/tipdm/index.html') soup = BeautifulSoup(rqq.content, 'lxml') dat = soup.select('.menu > li > a')
In [ ]:
names = [i.text for i in dat] href = [i['href'] for i in dat] print(names, href)
In [ ]:
import json with open('./temp.json', 'w') as f: json.dump({'names': names, 'href': href}, f, ensure_ascii=False)
In [ ]:
import os os.getcwd()
无
【创作不易,望点赞收藏,若有疑问,请留言,谢谢】