Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 返回空数组的scrapy xpath选择器_Python_Arrays_Scrapy - Fatal编程技术网

Python 返回空数组的scrapy xpath选择器

Python 返回空数组的scrapy xpath选择器,python,arrays,scrapy,Python,Arrays,Scrapy,这个response.xpath语句返回一个空数组,我不太清楚原因。我正在尝试检索@alt result。这就是我尝试过的 response.xpath('//*[@id="all_teams_war_images"]/div/a/img/@alt').extract() 奇怪的是,这将返回该div中的所有元素 response.xpath('//*[@id="all_teams_war_images"]').extract() 这是我正试图抓取的网站您试图解析的内容隐藏在HTML评论部分。

这个response.xpath语句返回一个空数组,我不太清楚原因。我正在尝试检索@alt result。这就是我尝试过的

response.xpath('//*[@id="all_teams_war_images"]/div/a/img/@alt').extract()
奇怪的是,这将返回该div中的所有元素

response.xpath('//*[@id="all_teams_war_images"]').extract()

这是我正试图抓取的网站

您试图解析的内容隐藏在HTML评论部分。有关详细信息,请参见此

我相信“/*[@id=all\u teams\u war\u images]/div/a/img/@alt”只查看具有该id的元素下的第一个子元素,该元素不包含任何元素。你是怎么得到那个xpath的?你是手工打字的吗?