Python 从页面的检查元素复制CSS选择器的BeautifulSoup select方法不会返回任何内容 链接http://shop.oreilly.com/product/0636920028154.do' req=requests.getlink bs=BeautifulSoupreq.text,“html.parser”

Python 从页面的检查元素复制CSS选择器的BeautifulSoup select方法不会返回任何内容 链接http://shop.oreilly.com/product/0636920028154.do' req=requests.getlink bs=BeautifulSoupreq.text,“html.parser”,python,css,web-scraping,beautifulsoup,Python,Css,Web Scraping,Beautifulsoup,我想在本页中获得图书描述,我使用了inspect元素并复制了相关段落的CSS选择器: bs.选择'div.description:nth-child2>span:nth-child2' 不幸的是,代码返回一个空列表,我尝试了代码的多种变体,例如: bs.选择'div.description:nth-of-type2>span:nth-of-type2' bs.选择“div.description” bs.选择“divdescription t-description” 它们都返回一个空列表,有什

我想在本页中获得图书描述,我使用了inspect元素并复制了相关段落的CSS选择器:

bs.选择'div.description:nth-child2>span:nth-child2' 不幸的是,代码返回一个空列表,我尝试了代码的多种变体,例如:

bs.选择'div.description:nth-of-type2>span:nth-of-type2' bs.选择“div.description” bs.选择“divdescription t-description”
它们都返回一个空列表,有什么问题吗?

您找的类没有正确的标记。描述位于一个标记下,您可以通过查找特定标记来获取该标记

或使用。选择

输出:


还有没有办法通过.select方法检索此信息?是的。我更新了它
import requests
from bs4 import BeautifulSoup

link = 'http://shop.oreilly.com/product/0636920028154.do'
req = requests.get(link)
bs = BeautifulSoup(req.text, 'html.parser')

desc = bs.find('h2', {'class':'t-description-heading'}).find_next('span').text
desc = bs.select('h2.t-description-heading')[0].find_next('span').text
'Get a comprehensive, in-depth introduction to the core Python language with this hands-on book. Based on author Mark Lutz’s popular training course, this updated fifth edition will help you quickly write efficient, high-quality code with Python. It’s an ideal way to begin, whether you’re new to programming or a professional developer versed in other languages.Complete with quizzes, exercises, and helpful illustrations,  this easy-to-follow, self-paced tutorial gets you started with both Python 2.7 and 3.3— the latest releases in the 3.X  and 2.X lines—plus all other releases in common use today. You’ll also learn some advanced language features that recently have become more common in Python code.Explore Python’s major built-in object types such as numbers, lists, and dictionariesCreate and process objects with Python statements, and learn Python’s general syntax modelUse functions to avoid code redundancy and package code for reuseOrganize statements, functions, and other tools into larger components with modulesDive into classes: Python’s object-oriented programming tool for structuring codeWrite large programs with Python’s exception-handling model and development toolsLearn advanced Python tools, including decorators, descriptors, metaclasses, and Unicode processing'