代码
import requests
from bs4 import BeautifulSoup
url = 'http://product.pconline.com.cn/mobile/'
response = requests.get(url)
html = response.text
print html
soup = BeautifulSoup(html, 'lxml')
site = soup.find_all('img', class_="pic")
print site
目标网站:http://product.pconline.com.cn/mobile/
打算爬取的是手机图片标签,运行上面这段代码后打印的site得到是空的。
图片部分html片段:
<img class="pic" alt="华为Mate8/3GB+32GB版" title="麒麟950处理器、6寸超大屏、超高屏占比、超窄边框,3GB+32GB全网通版本" src="http://img.pconline.com.cn/images/product/5807/580761/q_sn8.jpg" height="150" width="200">
我这边是可以的,不知道会不会是编码的问,或者是lxml扩展的问题