<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="337364" data-post-id="337364">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="RicoTrevisan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/RicoTrevisan/120/32751_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  RicoTrevisan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I got the spider to work in local in my Phoenix app, but when I go to deploy it I get this error:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">No spiders found to auto-load: %MatchError{term: {:error, :enoent}}
</code></pre>
<p>All the files are there. Do I have to add something to my Dockerfile?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="337364" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/crawly-a-high-level-web-crawling-scraping-framework-for-elixir/31800/42">Post #41</a>
	                </div>
	            </div>
              <div id="likers-container-337364" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="337364"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #41"></div>
  </section>
</div>
    <div class="postbit" id="337494" data-post-id="337494">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="RicoTrevisan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/RicoTrevisan/120/32751_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  RicoTrevisan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="kasvith" data-post="35" data-topic="31800">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kasvith/48/21600_2.png" class="avatar"> kasvith:</div>
<blockquote>
<p>One limitation is see in Crawly is inability to submit urls after a spider started, we have a list of urls stored in a db and need to crawl it by some limit</p>
</blockquote>
</aside>
<p>I think you can add more requests when the spider is running by using <a href="https://hexdocs.pm/crawly/Crawly.RequestsStorage.html#content" rel="noopener nofollow ugc">Crawly.RequestStorage.store/2</a>. I think my challenge was similar to yours: Weekly I have to go through a long list of urls (20k+) to update their status. At first I started my spider by listing all the records from the db, but that would keep the db connection open for too long. Then I started looking into doing some sort of pagination.</p>
<p>I came up with this solution:</p>
<pre data-code-wrap="ex"><code class="lang-ex"># PluginProphet.AppSpider.ex

  def init do
    # set up an ets table to keep track of the pagination
    :ets.new(@ets_table, [:set, :public, :named_table])
    :ets.insert(@ets_table, {:current_page, 1})

    # format the initial urls
    urls =
      Apps.list_apps(1, @per_page)
      |&gt; Enum.map(&amp;get_app_url/1)

    [start_urls: urls]
  end

  @impl Crawly.Spider
  def parse_item(response) do
    should_add_more_requests?()
    # ...
    # do some work
    # ...
  end

  defp should_add_more_requests?() do
    # grab the current requests
    {:requests, requests} = Crawly.RequestsStorage.requests(PluginProphet.AppSpider)

    # check if needs to add more requests
    if Enum.count(requests) &lt; 2 do
      [{:current_page, current_page}] = :ets.lookup(@ets_table, :current_page)
      next_page = current_page + 1
      :ets.insert(@ets_table, {:current_page, next_page})

      new_requests =
        Apps.list_apps(next_page, @per_page)
        |&gt; Enum.map(&amp;get_app_url/1)
        |&gt; Enum.map(&amp;Crawly.Request.new(&amp;1))

      Crawly.RequestsStorage.store(PluginProphet.AppSpider, new_requests)
    end
  end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="337494" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/crawly-a-high-level-web-crawling-scraping-framework-for-elixir/31800/43">Post #42</a>
	                </div>
	            </div>
              <div id="likers-container-337494" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="337494"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #42"></div>
  </section>
</div>
    <div class="postbit" id="338257" data-post-id="338257">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="RicoTrevisan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/RicoTrevisan/120/32751_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  RicoTrevisan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>How do I wipe the spider’s memory and run it again?</p>
<p>I would like to run the spider on a list of urls from my db. The way that the spider parses items could add a repeated item to the list of urls to crawl. Because of that I turned on <code>Crawly.Middlewares.UniqueRequest</code>. That works fine the first time. However, when I try to rerun the spider, it will log out a bunch of these:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">...
[debug] Dropping request: [some_url], as it's already processed
[debug] Dropping request: [some_url], as it's already processed
...
</code></pre>
<p>I’ve tried to delete the <code>dets_simple_storage</code> file, I tried to force wipe the spider’s RequestsStorage on init with</p>
<pre data-code-wrap="ex"><code class="lang-ex">...
Crawly.RequestsStorage.store(PluginProphet.AppSpider, [])
...
</code></pre>
<p>But none worked. The only way is to turn off <code>Crawly.Middlewares.UniqueRequest</code>.</p>
<p>Is there a way to wipe the spider’s memory?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="338257" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/crawly-a-high-level-web-crawling-scraping-framework-for-elixir/31800/44">Post #43</a>
	                </div>
	            </div>
              <div id="likers-container-338257" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="338257"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #43"></div>
  </section>
</div>
    <div class="postbit" id="338366" data-post-id="338366">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="oltarasenko" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/oltarasenko/120/15709_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  oltarasenko
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi Rico!</p>
<p>The requests middlewares use RequestsStorageWorker process in order to store information. The process itself is supposed to die when the spider finishes. Isn’t it the case for you?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="338366" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/crawly-a-high-level-web-crawling-scraping-framework-for-elixir/31800/45">Post #44</a>
	                </div>
	            </div>
              <div id="likers-container-338366" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="338366"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #44"></div>
  </section>
</div>
    <div class="postbit" id="338572" data-post-id="338572">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="RicoTrevisan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/RicoTrevisan/120/32751_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  RicoTrevisan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks, indeed that is working as you mentioned. I was in dev starting / stopping the spider manually and never gave it a chance to stop properly.<br>
In any case, after more consideration, I’ve decided to keep it off.</p>
<hr>
<p>I’m using Crawly in a Phoenix application. I see Crawly automatically looks for spiders in <code>./spiders</code>. I normally put all my backend modules in <code>./lib/my_app</code>. Is there a way to change the default folder from <code>./spiders</code> to <code>./lib/my_app/spiders</code>?</p>
<hr>
<p>Thanks again for Crawly.<br>
I’m hoping to contribute back to it – as soon as I figure out how to better display the docs graphs in both Hex and in the IDE.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="338572" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/crawly-a-high-level-web-crawling-scraping-framework-for-elixir/31800/46">Post #45</a>
	                </div>
	            </div>
              <div id="likers-container-338572" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="338572"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>