Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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如何从数据href获取值_Python_Xpath_Scrapy_Css Selectors_Scrapy Spider - Fatal编程技术网

Python Scrapy如何从数据href获取值

Python Scrapy如何从数据href获取值,python,xpath,scrapy,css-selectors,scrapy-spider,Python,Xpath,Scrapy,Css Selectors,Scrapy Spider,我正在尝试刮一堆链接,或者一些可以附加到根域以创建链接的东西 html本身如下所示: <div class="container-item listing-layout-item selectorgadget_selected" data-href="/groups/viral-communications/overview/" '=""> <div class="container-item listing-layout-item selectorgadget_sug

我正在尝试刮一堆链接,或者一些可以附加到根域以创建链接的东西

html本身如下所示:

<div class="container-item listing-layout-item selectorgadget_selected" data-href="/groups/viral-communications/overview/" '="">   
<div class="container-item listing-layout-item  selectorgadget_suggested" data-href="/groups/social-machines/overview/" '="">
<div class="container-item listing-layout-item  selectorgadget_suggested" data-href="/groups/space-enabled/overview/" '="">

尝试使用

response.xpath('//div/@data-href').extract()
要获取所需的值,请尝试使用

response.xpath('//div/@data-href').extract()
获取所需的值