title: requests python 500 internal error
body: <p>This is my code the last curl gets a 500 error most of the time, can somebody explain to me why this is happening I'm a newbie here!</p>
  
  <pre><code> headers = {"Accept-Encoding": "gzip, deflate, sdch, br",
              "Accept-Language": "en-GB,en-US;q=0.8,en;q=0.6",
              "Upgrade-Insecure-Requests": "1",
              "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36",
              "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
              "Connection": "keep-alive --compressed"}
              url_ = "https://www.apct.gov.in/apportal/index.aspx"
              r = requests.get(url_,headers=headers)
              #open("/tmp/1.html","w").write(r.content)    
              c1 = r.cookies
  
              headers = {
          'Accept-Language': 'en-GB,en-US;q=0.8,en;q=0.6',
          'Upgrade-Insecure-Requests': '1',
          'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36',
          'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
          'Referer': 'https://www.apct.gov.in/apportal/index.html',
          'Connection': 'keep-alive --compressed'}
  
  
              url = "https://www.apct.gov.in/apportal/index.aspx"
              r1 = requests.get(url,headers=headers,cookies=c1)
              c2 = r1.cookies
              # f = open("/tmp/1.html","w+")
              # f.write(r.content)
              url = "https://www.apct.gov.in/apportal/Search/ViewAPVATdealers.aspx"
              time.sleep(2.5) 
  
  
  
              headers = {  'Accept-Encoding': 'gzip, deflate, sdch, br',
          'Accept-Language': 'en-GB,en-US;q=0.8,en;q=0.6',
          'Upgrade-Insecure-Requests': '1',
          'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36',
          'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
          'Referer': 'https://www.apct.gov.in/apportal/index.html',
          'Connection': 'keep-alive'}
  
  
  
              #r = requests.get(url,headers=headers,cookies=c2,timeout=60,verify=True)
              Cert ='certifi.old_where()'
              r = requests.get('https://www.apct.gov.in/apportal/Search/ViewAPVATdealers.aspx', headers=headers, cookies=c2,verify=certifi.old_where())
              r = requests.get('https://www.apct.gov.in/apportal/Search/ViewAPVATdealers.aspx', headers=headers, cookies=c2, timeout=60,verify=True)
              soup = BeautifulSoup(r.content)
              try: 
                  view_state = soup.find('input', attrs={'id': '__VIEWSTATE'}).get("value")
              except:
                  time.sleep(2.5)
                  r = requests.get('https://www.apct.gov.in/apportal/Search/ViewAPVATdealers.aspx', headers=headers, cookies=c2, timeout=60,verify=True)
                   #pdb.set_trace()
              # r = requests.get(url,headers=headers,cookies=c2,timeout=60, verify=False)
              c3 = r.cookies
              soup = BeautifulSoup(r.content)
  </code></pre>
  
  <p>This is my code above, the last curl is getting a 500 error most of the time - can somebody explain to me why this is happening </p>