title: Downloading multiple tickers data from Yahoo Finance
body: <p>I saw this code that Andrej Kesely posted on StackOverflow. I really find it very helpful, but I am trying to download multiple tickers instead of one ticker.  <a href="https://stackoverflow.com/questions/68263449/cannot-scrape-from-table-in-yahoo-finance?answertab=votes#tab-top">Cannot scrape from table in yahoo finance</a></p>
  <p>Currently, I am downloading multiple tickers for prices, and I use the ['AAPL', 'MSFT', 'AMZN'], so I tried to change</p>
  <p>url = [&quot;https://finance.yahoo.com/quote/AAPL/key-statistics?p=AAPL&quot;,&quot;https://finance.yahoo.com/quote/AAPL/key-statistics?p=MSFT&quot;]</p>
  <p>It didn't work, I was wondering if anyone know how to change it for a url. Thank you so much.</p>
  <pre><code>import requests
  from bs4 import BeautifulSoup
  
  
  url = &quot;https://finance.yahoo.com/quote/AAPL/key-statistics?p=AAPL&quot;
  
  headers = {
      &quot;User-Agent&quot;: &quot;Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0&quot;
  }
  
  soup = BeautifulSoup(requests.get(url, headers=headers).content, &quot;html.parser&quot;)
  
  for t in soup.select(&quot;table&quot;):
      for tr in t.select(&quot;tr:has(td)&quot;):
          for sup in tr.select(&quot;sup&quot;):
              sup.extract()
          tds = [td.get_text(strip=True) for td in tr.select(&quot;td&quot;)]
          if len(tds) == 2:
              print(&quot;{:&lt;50} {}&quot;.format(*tds))
  </code></pre>