【发布时间】:2017-02-22 01:01:27
【问题描述】:
我在jupyter上运行这个,但没有任何反应,我不知道原因。
谁能帮帮我?
import requests
from bs4 import BeautifulSoup
res = requests.get("https://s.taobao.com/search?q=%E5%92%96%E5%95%A1%E5%A3%B6&imgfile=&commend=all&ssid=s5-e&search_type=item&sourceId=tb.index&spm=a21bo.50862.201856-taobao-item.1&ie=utf8&initiative_id=tbindexz_20161013")
soup = BeautifulSoup(res.text, "html.parser")
for item in soup.select('.item'):
print (item.select('strong')[0].text)
【问题讨论】:
-
您好,欢迎来到 SO,请阅读 How to Ask 和 minimal reproducible example 以提出更好的问题。最后在最后一行你有 '.item' ,afaik 这将完全选择文本 .item 而不是变量 item。
标签: beautifulsoup ipython python-3.5 jupyter-notebook