欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python基于BeautifulSoup實(shí)現(xiàn)抓取網(wǎng)頁(yè)指定內(nèi)容的方法

 更新時(shí)間:2015年07月09日 10:12:50   作者:光索與諾  
這篇文章主要介紹了python基于BeautifulSoup實(shí)現(xiàn)抓取網(wǎng)頁(yè)指定內(nèi)容的方法,涉及Python使用BeautifulSoup模塊解析html網(wǎng)頁(yè)的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了python基于BeautifulSoup實(shí)現(xiàn)抓取網(wǎng)頁(yè)指定內(nèi)容的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

# _*_ 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")

希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論