<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                抓取 http://sh.ganji.com/fang1 中的數據 在命令行中輸入 ~~~ scrapy shell http://sh.ganji.com/fang1/ ~~~ 可以用response查看是否抓取成功,如果返回200的數據,說明抓取成功了 ~~~ >>> response <200 http://sh.ganji.com/fang1/> ~~~ 我們可以用view(response)來查看抓取的內容,在命令行中輸入后,會用默認的瀏覽器打開抓取下來的網頁 ~~~ view(response) ~~~ 如果我們要抓取網頁中的某個數據,可以用response.xpath('元素/text()').extract()來獲取,比如下面的命令就返回一個2600的文本 ~~~ >>> response.xpath('//*[@id="puid-2996870036"]/dl/dd[5]/div[1]/span[1]/text()').extract() ['2600'] ~~~ > 備注:xpath中的值,可以用谷歌瀏覽器打開網址后,按F12,在要抓取的目標上面Copy->copy xPath獲取 如果我們要獲取這個列表頁中的所有價格數據,可以用上面的ID換成class獲取一組元素,比如 ~~~ >>> response.xpath("//div[@class='f-list-item ershoufang-list']/dl/dd[5]/div[1]/span[1]/text()").extract() ['2600', '3900', '4000', '6200', '2500', '3500', '2300', '50000', '4000', '2600', '4700', '2900', '2300', '2800', '3500', '2800', '7500', '5300', '4000', '3900', '1200', '1350', '6800', '1950', '5000', '1700', '5500', '1500', '5700', '3500', '2000', '13500', '1000', '27000', '1950', '1800', '3500', '1800', '1100', '4000', '4000', '1150', '2100', '1600', '3500', '3900', '3500', '3500', '3300', '4700', '3300', '3300', '3800', '1400', '3090', '3800', '4000', '2000', '2800', '3300', '3100', '3500', '3200', '3500', '1380', '3500', '3200', '2800', '1200', '7200', '2000', '3100', '2500', '1000', '2200', '900', '1800', '1300', '1650', '1650', '1700', '1800', '1800', '1100', '4300', '1200', '10000', '3300', '1800', '3500', '3500', '6800', '4700', '3000', '1280'] >>> ~~~ 我們可以用len()來統計一共獲取到幾個,比如下面的代碼統計出來是95個: ~~~ >>> len(response.xpath("//div[@class='f-list-item ershoufang-list']/dl/dd[5]/div[1]/span[1]/text()").extract()) 95 ~~~ 不顯示log,可以用 ~~~ scrapy crawl --nolog xxx ~~~
                  <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>

                              哎呀哎呀视频在线观看