()
| 59 | |
| 60 | |
| 61 | def main(): |
| 62 | temp = get_company_list() |
| 63 | companies = temp if temp else demo_companies |
| 64 | |
| 65 | all_gstin_data = "" |
| 66 | third_party_gstin_site = ( |
| 67 | "https://www.knowyourgst.com/gst-number-search/by-name-pan/" |
| 68 | ) |
| 69 | |
| 70 | # Getting the CSRF value for further RESTful calls. |
| 71 | page_with_csrf = requests.get(third_party_gstin_site) |
| 72 | soup = BeautifulSoup(page_with_csrf.text, "html.parser") |
| 73 | csrf_token = soup.find("input", {"name": "csrfmiddlewaretoken"})["value"] |
| 74 | |
| 75 | for company in companies: |
| 76 | gstins = fetch_gstins(company, csrf_token) |
| 77 | |
| 78 | # Only include GSTINs for Bengaluru and Mumbai-based companies |
| 79 | comma_separated_gstins = ", ".join( |
| 80 | [g for g in gstins if g.startswith(("27", "29"))] |
| 81 | ) |
| 82 | |
| 83 | all_gstin_data += f"{company} = {comma_separated_gstins}\n\n" |
| 84 | |
| 85 | # Delaying for false DDOS alerts on the third-party site |
| 86 | time.sleep(0.5) |
| 87 | |
| 88 | # Printing the data |
| 89 | print(all_gstin_data) |
| 90 | |
| 91 | |
| 92 | if __name__ == "__main__": |
no test coverage detected