title: Python: Skip url in scraping process conditionally
body: <p>I'm scraping property ads by BS4, using the following code,</p>
  
  <pre><code># get_ad_page_urls collects all ad urls displayed on page
  def get_ad_page_urls(link): 
      BS4_main(link) # BS4_main parses the link and returns the "container" object
      return [link.get("href") for link in container.findAll("a", href=re.compile("^(/inmueble/)((?!:).)*$"))]
  
  # get_ad_data obtains data from each ad
  def get_ad_data(ad_page_url):
      ad_data={}
      response=requests.get(root_url+ad_page_url)
      soup = bs4.BeautifulSoup(response.content, 'lxml')
  
      &lt;collecting data code here&gt;
  
      return ad_data
  </code></pre>
  
  <p>This works fine. By the following multiprocessing code, I scrape all the ads,</p>
  
  <pre><code>def show_ad_data(options):
      pool=Pool(options)
      for link in page_link_list:
          ad_page_urls = get_ad_page_urls(link)
          results=pool.map(get_ad_data, ad_page_urls)    
  </code></pre>
  
  <p><strong>Now the issue:</strong></p>
  
  <p>Particular ads should be skipped. Those ads display a specific text, by which they are recognisable. I'm new to using <code>def</code> functions, I don't know how to tell the code to skip to the next <code>ad_page_url</code>. </p>
  
  <p>I think the "skipping" code should be placed between <code>soup = bs4.BeautifulSoup(response.content, 'lxml')</code> and <code>&lt;collecting data code here&gt;</code>. Something like,</p>
  
  <pre><code># "skipping" semi-code
  for text in soup:
      if 'specific text' in text:
          continue
  </code></pre>
  
  <p>but I'm not sure if using <code>def</code> functions allows for applying <code>continue</code>
  on iterations. </p>
  
  <p>How should I modify the code such that it skips an ad when the <code>specific</code> text is on the page?</p>