通过本文主要向大家介绍了python beautifulsoup,python beautiful,beautiful4包python,beautifulsoup,beautifulsoup安装等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
本文实例讲述了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")
</div>
希望本文所述对大家的Python程序设计有所帮助。
</div>您可能想查找下面的文章:
- Python利用Beautiful Soup模块创建对象详解
- Python利用Beautiful Soup模块修改内容方法示例
- Python利用Beautiful Soup模块搜索内容详解
- Python利用Beautiful Soup模块创建对象详解
- Python利用Beautiful Soup模块修改内容方法示例
- Python使用BeautifulSoup库解析HTML基本使用教程
- python基于BeautifulSoup实现抓取网页指定内容的方法
- Python中使用Beautiful Soup库的超详细教程
- Python中使用Beautiful Soup库的超详细教程
- python使用BeautifulSoup分页网页中超链接的方法

