import requests |
from bs4 import BeautifulSoup |
|
url = 'https://yuncode.net/list/python' |
wb_data = requests.get(url) |
soup = BeautifulSoup(wb_data.content) |
#获取最新python代码链接写入文件 |
content = soup.select( ".type_column .title_title a" ) |
links_file = open ( 'links.txt' , 'a' ) #避免覆盖已有数据,用添加模式`a`写入 |
for i in content: |
links_file.write(i[ 'href' ] + "\n" ) #写入链接信息 |
links_file.close() #写完后关闭 |