How to modify my code to scrape these links?
<p>I am new to use python scrapy, and my scrapy version is 1.1.3. I want to get a link list in <a href="http://i.stack.imgur.com/ZrLsf.png" rel="nofollow">this part</a> on <a href="https://www.wikipedia.org/" rel="nofollow">https://www.wikipedia.org/</a>. How should I modify my code?    </p>

<pre><code>import scrapy

class LinkSpider(scrapy.Spider):
    name = "links"
    start_urls = [
        'https://www.wikipedia.org/',
    ]

    def parse(self, response):
        for link in response.xpath('//div/ul/li/a'): 
            yield{
                'link': link.extract()
            }
</code></pre>

<p>Above is my code in my project folder/spiders/spiders.py</p>

<p>What I get is </p>

<pre><code>[
{"link": "&lt;a href=\"//de.wikipedia.org/\" lang=\"de\"&gt;Deutsch&lt;/a&gt;"},
{"link": "&lt;a href=\"//en.wikipedia.org/\" lang=\"en\" title=\"English\"&gt;English&lt;/a&gt;"},
{"link": "&lt;a href=\"//es.wikipedia.org/\" lang=\"es\"&gt;Espa\u00f1ol&lt;/a&gt;"},
{"link": "&lt;a href=\"//fr.wikipedia.org/\" lang=\"fr\"&gt;Fran\u00e7ais&lt;/a&gt;"},
{"link": "&lt;a href=\"//it.wikipedia.org/\" lang=\"it\"&gt;Italiano&lt;/a&gt;"},
{"link": "&lt;a href=\"//nl.wikipedia.org/\" lang=\"nl\"&gt;Nederlands&lt;/a&gt;"},
{"link": "&lt;a href=\"//ja.wikipedia.org/\" lang=\"ja\" title=\"Nihongo\"&gt;\u65e5\u672c\u8a9e&lt;/a&gt;"},
{"link": "&lt;a href=\"//pl.wikipedia.org/\" lang=\"pl\"&gt;Polski&lt;/a&gt;"},
{"link": "&lt;a href=\"//ru.wikipedia.org/\" lang=\"ru\" title=\"Russkiy\"&gt;\u0420\u0443\u0441\u0441\u043a\u0438\u0439&lt;/a&gt;"},
{"link": "&lt;a href=\"//ceb.wikipedia.org/\" lang=\"ceb\"&gt;Sinugboanong Binisaya&lt;/a&gt;"}
]
</code></pre>

<p>and I expect something like a list only contains links like "//de.wikipedia.org/".</p>

<p>You are missing couple of things,</p>

<ul>
<li>You need to add attribute @href to get the value</li>
<li><p>Your href value on first index, you need to add index number.</p>

<pre><code>import scrapy
class LinkSpider(scrapy.Spider):
    name = "links"
    start_urls = ['https://www.wikipedia.org/', ]

    def parse(self, response):
        for link in response.xpath('//div/ul/li/a/@href'):
            yield{'link': link.extract()[0]}
</code></pre></li>
</ul>

python scrapy