MCPcopy Create free account
hub / github.com/geekcomputers/Python / main

Function main

gstin_scraper.py:61–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59
60
61def 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
92if __name__ == "__main__":

Callers 1

gstin_scraper.pyFile · 0.70

Calls 3

get_company_listFunction · 0.85
fetch_gstinsFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected