Python练手项目0009
2017-01-10 13:25
267 查看
本项目采用的是https://github.com/Yixiaohan/show-me-the-code中所提供的练习项目,所有代码均为原创,转载请注明,谢谢。
问题描述:给出一个html文件,找出里面的链接,其具体代码如下:
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 10 13:18:55 2017
@author: sky
"""
import urllib2
from bs4 import BeautifulSoup
url = "http://www.baidu.com"
page = urllib2.urlopen(url)
file = open('result.txt','w')
soup = BeautifulSoup(page)
links = soup.findAll('a')
for link in links:
a = link['href']
file.write(str(a))
print(link['href'])
file.close()
问题描述:给出一个html文件,找出里面的链接,其具体代码如下:
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 10 13:18:55 2017
@author: sky
"""
import urllib2
from bs4 import BeautifulSoup
url = "http://www.baidu.com"
page = urllib2.urlopen(url)
file = open('result.txt','w')
soup = BeautifulSoup(page)
links = soup.findAll('a')
for link in links:
a = link['href']
file.write(str(a))
print(link['href'])
file.close()
相关文章推荐
- python练手项目(1)——字符图片生成
- Python练手项目0016
- 70个Python练手项目列表(都有完整教程)
- 有哪些适合新手练手的Python项目?
- 【Python】 Flask 缘分匹配练手项目
- Python练手项目0 - 给头像右上角添加数字
- Python练手项目0014
- Python练手项目
- Python学习路径及练手项目合集
- python练手项目
- Python练手项目0006
- python练手项目0005
- Python练手项目0015
- 有哪些适合新手练手的Python项目?
- Python练手项目(2)——200行实现2048小游戏
- Python之路【第二十四篇】:Python学习路径及练手项目合集
- python练手项目0007
- 利用Caffe+Python实现Kaggle上Digit Recognition练手项目
- 10个Python练手项目