python练习 抓取web页面
2010-11-17 16:13
453 查看
from urllib import urlretrieve
def firstNonBlank(lines):
for eachLine in lines:
if not eachLine.strip():
continue
else:
return eachLine
def firstLast(webpage):
f=open(webpage)
lines=f.readlines()
f.close
print firstNonBlank(lines),
lines.reverse()
print firstNonBlank(lines),
def download(url= 'http://search.51job.com/jobsearch/advance_search.php',process=firstLast):
try:
retval = urlretrieve(url) [0]
except IOError:
retval = None
if retval:
process(retval)
if __name__ == '__main__':
download()
def firstNonBlank(lines):
for eachLine in lines:
if not eachLine.strip():
continue
else:
return eachLine
def firstLast(webpage):
f=open(webpage)
lines=f.readlines()
f.close
print firstNonBlank(lines),
lines.reverse()
print firstNonBlank(lines),
def download(url= 'http://search.51job.com/jobsearch/advance_search.php',process=firstLast):
try:
retval = urlretrieve(url) [0]
except IOError:
retval = None
if retval:
process(retval)
if __name__ == '__main__':
download()
相关文章推荐
- python模拟浏览器webdriver登陆网站后抓取页面并输出
- Python练习 requests+BeautifulSoup抓取ZD页面
- Python Post and Get 登陆web后台系统并抓取页面
- Python Post and Get 登陆web后台系统并抓取页面
- Python中网络页面抓取和页面分析
- Python爬虫练习之三:抓取游民星空搞笑动态图
- #小练习 使用正则抓取oschina博客专区首页数据 分类: python 小练习 正则表达式 2013-11-11 17:22 604人阅读 评论(0) 收藏
- 如何用 Python 实现 Web 抓取?
- 爬虫案例---Python2X版本抓取京东手机页面的图片
- 【极客学院】-python学习笔记-4-单线程爬虫 (提交表单抓取信息,实战练习)
- Python中网络页面抓取和页面分析
- Python实现抓取页面上链接的简单爬虫分享
- python 抓取页面不显示图片问题
- python 实现页面数据抓取
- Using Django with GAE Python 后台抓取多个网站的页面全文
- Python学习(从Web抓取信息)
- 分享:十Python之Http Web服务(网页抓取二)
- 最近看了一段时间Python,练习写了一个抓取淘女郎的爬虫,话不多说,上代码
- 用python写了一个简单的模拟浏览器抓取网页的库webclient
- python抓取页面数据实例