How to wrap this into a recursive call
<p>I'm writing a little spider in python. It hits a page, gets all the links on the page according to a pattern, goes to each of those pages, and repeats.</p>

<p>I need to make this recursive somehow. Below are the url patterns:</p>

<pre><code>www.example.com
</code></pre>

<p>Then I get all links based on a regex, then I visit each page.</p>

<p>Recursive part:</p>

<p>Say I am visiting a page with a url like:</p>

<pre><code>www.example.com/category/1
</code></pre>

<p>Now if this page contains links like:</p>

<pre><code>www.example.com/category/1_234
</code></pre>

<p>(basically the same url, except it has an additional "_234234")</p>

<p>I visit that page, then check for a url like:</p>

<pre><code>www.example.com/category/1_234_4232
</code></pre>

<p>(again, same url plus an underscore and a number)</p>

<p>I keep doing this until there are no more links fitting this pattern.</p>

<pre><code>1. visit a category page
2. does it contain links with the same url + "_dddd" if yes, visit that page
3. back to #2 unless no links
</code></pre>

<p>I don't need the regex, I just need help with structuring the recursive call.</p>
