小编Shu*_* B.的帖子

How to extract text as well as hyperlink text in scrapy?

I want to extract from following html code:

<li>
    <a test="test" href="abc.html" id="11">Click Here</a>
    "for further reference"
</li>
Run Code Online (Sandbox Code Playgroud)

I'm trying to do with following extract command

response.css("article div#section-2 li::text").extract()
Run Code Online (Sandbox Code Playgroud)

But it is giving only "for further reference" line And Expected output is "Click Here for further reference" as a one string. How to do this? How to modify this to do the same if following patterns are there:

  1. Text Hyperlink Text
  2. Hyperlink Text
  3. Text Hyperlink

csv scrapy web-scraping

2
推荐指数
1
解决办法
2058
查看次数

标签 统计

csv ×1

scrapy ×1

web-scraping ×1