如图,Xpath取得值只有一半,完整的网址被截断了。
如图,css选择器也只取到了一半的网址,被截断了。
代码如下:
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
并不是被截断了,而是只显示这么多。你要提取url,应该这么写: