av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術文章
文章詳情頁

python - scrapy xpath 頁面解析找不到

瀏覽:126日期:2022-06-28 15:02:38

問題描述

下面是頁面大類的html

<p class='house-item clearfix house-item-curr'><p class='item-photo fl'> <a href='http://www.4tl426be.cn/zufang/shbs12427828.html' target='_blank'><img src='https://imgsh.centanet.com/ctpostimage/a4/d5/4e4da3a2496299b2b26243565af6_220x165.jpg' src='https://imgsh.centanet.com/ctpostimage/a4/d5/4e4da3a2496299b2b26243565af6_220x165.jpg' alt='采菊苑租房2800元/月' style='display: inline-block;'></a></p><p class='item-info fl'> <h4 class='house-title'><a href='http://www.4tl426be.cn/zufang/shbs12427828.html' target='_blank' class='cBlueB'>采菊苑,77平兩房出租,毛坯3千,好談價!</a> </h4> <p class='f14 f000 mb_10'><a href='http://www.4tl426be.cn/xiaoqu/xq-pedpwawows/' target='_blank'>采菊苑</a><span class='f000 mr_10'>2室2廳</span><span class='f000'>77平</span> </p> <p class='f7b mb_10'>南北<em class='mrl_6'>|</em>高層<em class='mrl_6'>|</em>毛坯<em class='mrl_6'>|</em>2008年<em class='mrl_6'>|</em>整租 </p> <p class='f7b mb_15'>寶山-顧村 菊聯路68弄<a href='javascript:void(0)' value='/page/v1/common/maputil.aspx?x=121.372168&amp;y=31.354713' class=' icons_map jsmapicon '></a> </p> </p> <p class='item-pricearea fr'> <p class='price-nub cRed'>2800元/月</p> <p class='f14 f000 mb_15 fsm'>&nbsp;</p> </p><p class='clear'></p> </p>

我用xpath提取text 我的代碼是

class itcast(scrapy.Spider): name = ’SH’ allowd_domains = ['http://sh.centanet.com/'] start_urls = ['http://sh.centanet.com/zufang/p2/'] def parse(self,response):list = response.xpath('//p[@class=’//p[@class=’ouse-item clearfix house-item-curr’]')for i in list: name = i.xpath('//a[@class=’cBlueB’.text()]') print name[0]

我可以找到這個大類報錯是在 for i in list:name =f.xpath()這行,text提取不到。執行代碼找不到,幫我看看我是哪里不對,類似的我也試過好多次,沒辦法了,只能提問了希望能回答下 謝謝!

問題解答

回答1:

def parse(response): list = response.xpath('//p[@class=’house-item clearfix house-item-curr’]') for i in list:name = i.xpath('//a[@class=’cBlueB’]')print name[0].text

也許你是這個意思?

回答2:

name = i.xpath('//a[@class=’cBlueB’.text()]')這種寫法是錯誤的,text怎么能放在[]里面呢

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 在线中文字幕第一页 | 精品电影| 天天插天天操 | 欧美一区二区在线 | 中文天堂在线一区 | 久久99精品久久久久久国产越南 | 日韩毛片免费视频 | 成人免费视频观看视频 | 色婷婷av久久久久久久 | 成人免费精品视频 | 亚洲精品中文字幕 | 国产一级片一区二区三区 | 久热久热 | 久久精品免费观看 | 亚洲啪啪| 国产精品波多野结衣 | 不卡一二区 | 亚洲精品在线观 | 亚洲欧美日本国产 | 日韩中文在线 | 情侣av| 亚洲一区中文字幕 | 麻豆91av| www.成人.com | 中国美女一级黄色片 | 香蕉久久久 | 精品欧美乱码久久久久久1区2区 | 欧美高清视频一区 | 国产情品| 一区二区三区免费 | 亚洲一区二区在线播放 | 羞羞涩涩在线观看 | 午夜欧美一区二区三区在线播放 | 国产小视频在线观看 | 夜夜夜久久久 | 免费一级淫片aaa片毛片a级 | 国产日韩一区二区 | 天堂一区在线 | 欧美a∨ | 久久久久国产一区二区三区 | 欧美mv日韩mv国产网站91进入 |