| 42 | |
| 43 | |
| 44 | def fetch_gstins(company_name, csrf_token): |
| 45 | third_party_gstin_site = ( |
| 46 | "https://www.knowyourgst.com/gst-number-search/by-name-pan/" |
| 47 | ) |
| 48 | payload = {"gstnum": company_name, "csrfmiddlewaretoken": csrf_token} |
| 49 | |
| 50 | # Getting the HTML content and extracting the GSTIN content using BeautifulSoup. |
| 51 | html_content = requests.post(third_party_gstin_site, data=payload) |
| 52 | soup = BeautifulSoup(html_content.text, "html.parser") |
| 53 | site_results = soup.find_all(id="searchresult") |
| 54 | |
| 55 | # Extracting GSTIN specific values from child elements. |
| 56 | gstins = [result.strong.next_sibling.next_sibling.string for result in site_results] |
| 57 | |
| 58 | return gstins |
| 59 | |
| 60 | |
| 61 | def main(): |