<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                Selector選擇器有如下4個基本方法,為了使用方便,可以讓 `response.方法名` 直接調用: ```python xpath(query): 傳入xpath表達式,返回該表達式所對應的所有節點的selector list列表 。 調用:response.xpath(query) css(query): 傳入CSS表達式,返回該表達式所對應的所有節點的selector list列表. 調用:response.css(query) extract(): 序列化該節點為unicode字符串并返回list。 調用:response.extract() re(regex): 根據傳入的正則表達式對數據進行提取,返回unicode字符串list列表。 調用:response.re(regex) ``` ```python #books.py import scrapy class BooksSpider(scrapy.Spider): name = 'books' # 爬蟲名稱 allowed_domains = ['book.jd.com'] # 爬取范圍 start_urls = ['http://book.jd.com/'] # 爬蟲的入口url def parse(self, response): title_selector = response.xpath('//title/text()') print(type(title_selector)) # <class 'scrapy.selector.unified.SelectorList'> title_list = title_selector.extract() # 返回列表 title = title_selector.extract_first() # 返回第一個元素 print(title_list) # ['京東圖書_圖書_暢銷書_電子書_文娛_教育培訓_低價書-京東'] print(title) # 京東圖書_圖書_暢銷書_電子書_文娛_教育培訓_低價書-京東 pass ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看