Scrapy SgmlLinkExtractor how to define rule with regex
<p>I have a link like <code>http://www.example.com/kaufen/105975478</code></p>

<p>I only want to allow links that have "/kaufen/" in the url and which contain a 9 digit integer number at the end of the url. </p>

<p>I managed to allow only links containing "/kaufen/" with the following allow statement:</p>

<pre><code>allow=('/kaufen/', )
</code></pre>

<p>How can I extend the allow statement such that it only follows the links having a 9 digit number at the end?</p>

<p>You can use <code>\/kaufen\/[0-9]{9}</code></p>

<ul>
<li><code>\/kaufen\/</code> means /kaufen/ litteraly</li>
<li><code>[0-9]{9}</code> means 9 number chars</li>
</ul>

<p><a href="https://regex101.com/r/tH5pC7/1" rel="nofollow">https://regex101.com/r/tH5pC7/1</a></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var re = /\/kaufen\/[0-9]{9}/gi; 
var str = 'http://www.homegate.ch/kaufen/105975478';
var m;
 
while ((m = re.exec(str)) !== null) {
    if (m.index === re.lastIndex) {
        re.lastIndex++;
    }
    // View your result using the m-variable.
    console.log(m[0]);
}</code></pre>
</div>
</div>
</p>

python regex scrapy