python基于BeautifulSoup实现抓取网页指定内容的方法
2015-07-09 00:00
981 查看
本文实例讲述了python基于BeautifulSoup实现抓取网页指定内容的方法。分享给大家供大家参考。具体实现方法如下:
# _*_ coding:utf-8 _*_ #xiaohei.python.seo.call.me:) #win+python2.7.x import urllib2 from bs4 import BeautifulSoup def jd(url): page = urllib2.urlopen(url) html_doc = page.read() soup = BeautifulSoup(html_doc.decode('gb2312','ignore')) for i in soup.find_all('div', id="sortlist"): one = i.find_all('a') two = i.find_all('li') print ("%s %s" % (one,two)) jd("http://channel.jd.com/computer.html")
希望本文所述对大家的Python程序设计有所帮助。
相关文章推荐
- python冒泡排序简单实现方法
- Python中的anydbm模版和shelve模版使用指南
- Python中的fileinput模块的简单实用示例
- python文件随机读写例子
- python
- python
- python
- python 3.x和2.x区别
- python实现的websocket总结 —— wspy
- Python笔记:multiprocessing模块详解
- python编程之 环绕卫星轨道
- Python字符整数类型转换
- karloop介绍--hello world大家好,今天为大家介绍一款非常轻量级的的web开发框架,karloop框架。使用python开发 首先我们下载karloop源码进行安装。 源码地址 下载成
- adb connection python 一键 wifi 连接
- python基础(1)
- python装饰器
- epoll 简单用法
- tornado 源码初识
- python_queue多线程
- 提供给开发者 10 款最好的 Python IDE(转)