# _*_ 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测试数据/computer.html")
希望本文所述对大家的Python程序设计有所帮助。
查看更多关于python基于BeautifulSoup实现抓取网页指定内容的方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did89050