新人入坑爬虫的一个小小问题 麻烦各位大佬帮我讲讲

最近买了本爬虫书 他是用chrome 开发者工具的copyselectorr来获取元素地址
我按照书上爬取小猪租房网 比方说我怕取图片上的的地址按照copyselector 粘贴过来的是body > div.wrap.clearfix.con_bg > div.con_l > div.pho_info > p > span 但是程序运行不对输出空白 改成这样就对了'div.con_l > div.pho_info > p > span' 请问这是为什么呢 为什么删掉就行 本人目前大一 水平有限 望各位大佬用尽量简单的知识讲解图片说明 以下是我的代码 问题对应adresss那行

 #encoding:utf-8
from bs4 import BeautifulSoup
import requests
import time

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36'}


def get_links(url):
    wbdata = requests.get(url, headers=headers)
    print(wbdata.status_code)
    soup = BeautifulSoup(wbdata.text, 'lxml')
    links = soup.select('#page_list > ul > li > a')
    for link in links:
        href = link.get("href")
        get_info(href)


def get_info(url):

    wbdata = requests.get(url, headers=headers)
    soup = BeautifulSoup(wbdata.text, 'lxml')
    tittles = soup.select('div.pho_info > h4')
    addresss = soup.select('body > div.wrap.clearfix.con_bg > div.con_l > div.pho_info > p > span')
    prices = soup.select('#pricePart > div.day_l > span')
    for tittle, address, price in zip(tittles, addresss, prices):
        data={'tittle':tittle.get_text().strip(),'address':address.get_text().strip(),'price':price.get_text()}
        print(data)

if __name__ == '__main__':
    urls = ['http://bj.xiaozhu.com/search-duanzufang-p{}-0/'.format(number) for number in range(1, 3)]
    for ursl in urls:
        get_links(ursl)
        time.sleep(2)


你是真的执着,你看一下,body下取div,他只能取到 .detail_wrapper的div标签,查看soup的内容,又没错,取不出来当然可能是parser的问题导致没成功解析出来,你再试试换一个解析器
。发现能出结果了不是,这不是表明问题很可能是解析器设计者的某些东西没考虑全面,你非要在这种问题上较真

个人认为是不同浏览器造成的

为什么不考虑正则来爬数据呢?

class="wrap clearfix conbg"
这是相当于CSS的多继承,同时继承了wrap、clearfix和conbg,该三个class是并行的。
如果用div.wrap.clearfix.conbg的话,相当于是将这三个class串行了,依照代码的逻辑,应该会从div.wrap里面找clearfix,找得到再找conbg。
然而显然是找不到的。

这个网站的反爬虫做的比较好,如果单位时间内请求次数过多,就会将ip限制住
图片说明