title: How to scrape Table in several webpages using Beautiful Soup and Pandas?
body: <p>I'm new to python and bs4. I've tried for hours to scrape a table in several webpages using beautiful soup and pandas. When I scrape 2 pages it worked but when I attempted scraping all of the 13 webpages, I ran into trouble. When I changed the range function from 2 to 13, the code does not produce a DF nor a CSV file. What am I doing incorrectly?</p>
  <pre><code>dfs=[]
  
  for page in range(13):
      http = &quot;http://websitexample/Records?year=2020&amp;page={}&quot;.format(page+1)
  
      url = requests.get(http)
      soup = BeautifulSoup(url.text, &quot;lxml&quot;)
      table = soup.find('table')
      df_list = pd.read_html(url.text)
      df = pd.concat(df_list)
      
      links = []
      for tr in table.find_all(&quot;tr&quot;): 
          trs = tr.find_all(&quot;td&quot;)
          for each in trs:
              try: 
                  link = each.find('a')['href']
                  links.append(link)
              except: 
                  pass
      
      df['Link']= links
      dfs.append(df)
  
  final_df = pd.concat(dfs)
  final_df.to_csv(&quot;NewFileAll13.csv&quot;,index=False,encoding='utf-8-sig')
  </code></pre>
  <p>I get the error message:</p>
  <blockquote>
  <p>Value error: length of values does not match length of index.</p>
  </blockquote>
  <p>I would highly appreciate any advice provided. Thank you!</p>