Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.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/7/css/32.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/6/entity-framework/4.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
Html Scrapy css选择器:获取所有内部标记的文本_Html_Css_Scrapy - Fatal编程技术网

Html Scrapy css选择器:获取所有内部标记的文本

Html Scrapy css选择器:获取所有内部标记的文本,html,css,scrapy,Html,Css,Scrapy,我有一个标签,我想得到里面所有的文字可用。我正在这样做: response.css('mytag::text') 但是它只获取当前标记的文本,我还想获取所有内部标记的文本 我知道我可以这样做: response.xpath('//mytag//text()') 但是我想用css选择器来实现它。我怎样才能做到这一点 response.css('mytag *::text') *将访问mytag的所有内部标记,:text将获取每个标记的文本仅获取选定节点的文本 response.css('my

我有一个标签,我想得到里面所有的文字可用。我正在这样做:

response.css('mytag::text')
但是它只获取当前标记的文本,我还想获取所有内部标记的文本

我知道我可以这样做:

response.xpath('//mytag//text()')
但是我想用
css
选择器来实现它。我怎样才能做到这一点

response.css('mytag *::text')

*
将访问
mytag
的所有内部标记,
:text
将获取每个标记的文本

仅获取选定节点的文本

response.css('mytag::text')
获取选定节点及其子节点的文本

response.css('mytag ::text')
看看这两个版本之间的区别。唯一的区别是空间。如果没有空格,则只返回当前节点的文本/属性。如果有空格,则选择self和child节点的文本/属性

response.css('h1 a::attr(href)') # only current node attribute

response.css('h1 ::attr(href)') # current node and all child nodes attribute.

你能告诉我你从哪里弄来的吗?这对梅不起作用,主要是在刮痧中使用,而且没有任何问题。