本文實(shí)例講述了Python爬蟲(chóng)實(shí)現(xiàn)抓取京東店鋪信息及下載圖片功能。分享給大家供大家參考,具體如下:

這個(gè)是抓取信息的
from bs4 import BeautifulSoup
import requests
url = 'https://list.tmall.com/search_product.htm?q=%CB%AE%BA%F8+%C9%D5%CB%AE&type=p&vmarket=&spm=875.7931836%2FA.a2227oh.d100&from=mallfp..pc_1_searchbutton'
response = requests.get(url) #解析網(wǎng)頁(yè)
soup = BeautifulSoup(response.text,'lxml') #.text將解析到的網(wǎng)頁(yè)可讀
storenames = soup.select('#J_ItemList > div > div > p.productTitle > a') #選擇出商店的信息
prices = soup.select('#J_ItemList > div > div > p.productPrice > em') #選擇出價(jià)格的信息
sales = soup.select('#J_ItemList > div > div > p.productStatus > span > em') #選擇出銷售額的信息
for storename, price, sale in zip(storenames,prices,sales):
storename = storename.get_text().strip() #用get_text()方法篩選出標(biāo)簽中的文本信息,由于篩選結(jié)果有換行符\n所以用strip()將換行符去掉
price = price.get_text()
sale = sale.get_text()
print('商店名:%-40s價(jià)格:%-40s銷售額:%s'%(storename,price,sale)) #使打印出來(lái)的信息規(guī)范
print('----------------------------------------------------------------------------------------------')
本文標(biāo)題:Python爬蟲(chóng)實(shí)現(xiàn)抓取京東店鋪信息及下載圖片功能示例-創(chuàng)新互聯(lián)
瀏覽地址:http://chinadenli.net/article28/ceocjp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、搜索引擎優(yōu)化、外貿(mào)網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、做網(wǎng)站、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容
營(yíng)銷型網(wǎng)站建設(shè)知識(shí)