在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ Python Xpath、css選擇器,獲取的數(shù)據(jù)不完整?

Python Xpath、css選擇器,獲取的數(shù)據(jù)不完整?

如圖,Xpath取得值只有一半,完整的網(wǎng)址被截斷了。

clipboard.png
如圖,css選擇器也只取到了一半的網(wǎng)址,被截斷了。

clipboard.png
代碼如下:

class FspiderSpider(Spider):
    name = 'FSpider'
    allowed_domains = ['eastmoney.com']
    start_urls = ['http://finance.eastmoney.com/news/cgnjj_2.html']

    def parse(self, response):
        con_url = response.Xpath('/html/body/div[1]/div/div[2]/div[1]/div[2]/ul/li[20]/div/p[1]/a')
        print(con_url)
        pass
回答
編輯回答
撥弦

'/html/body/div[1]/div/div[2]/div[1]/div[2]/ul/li[20]/div/p[1]/a/@href'
完整的網(wǎng)址是什么樣的呢

2018年5月19日 01:49
編輯回答
別瞎鬧

并不是被截斷了,而是只顯示這么多。你要提取url,應(yīng)該這么寫:

con_url = response.xpath('/html/body/div[1]/div/div[2]/div[1]/div[2]/ul/li[20]/div/p[1]/a/@href').extract_first()
2017年11月2日 17:43