Skip to content

Preferred way to use a search bar #608

Answered by janbuchar
afuetterer asked this question in Q&A
Discussion options

You must be logged in to vote

First off, I'd definitely advise you to use request labels to differentiate the request types, but you may already be doing that.

Regarding handling the search bar, there are multiple high level approaches. I'd probably make a request for each of your search terms like this:

start_requests = [
  Request.from_url(url=f"https://secret-search-engine.com#{term}", label="search", keep_url_fragment=True) 
  for term in search_terms
]

await crawler.run(start_requests)

In your handler for the search label, you can extract the fragment from context.request.url, enter it into the search bar and handle the results in any way you see fit.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@afuetterer
Comment options

@janbuchar
Comment options

@afuetterer
Comment options

@janbuchar
Comment options

Answer selected by afuetterer
@afuetterer
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants