If you're trying to bypass or interact with a site that uses Cloudflare or some other JavaScript-based verification or CAPTCHA challenges, traditional tools like requests or even selenium may struggle without solving a visual or JS-based CAPTCHA manually or via services.
You mentioned using async_tls_client — which is likely referring to the tls-client Python wrapper or its underlying Go-based TLS fingerprinting HTTP client. It's capable of mimicking real browsers more closely than requests or aiohttp.
Use async_tls_client instead of Selenium or Requests, likely to bypass bot detection or CAPTCHA
Select "Kings County Surrogate's Court", set "ADMINISTRATION PETITION" as proceeding type, date range 04/01/2025 - 04/30/2025
Scrape the resulting table from: https://websurrogates.nycourts.gov/File/FileSearchResults
⚠️ BUT: Key Problem
This website requires JavaScript-based POST operations simulated within a browser session.
If you're not using a real browser (like Selenium), you have to:
Manually reproduce what the form POST does in real browsers
Handle cookies/session IDs
Simulate JavaScript-based dropdowns and ViewState/CSRF tokens (if they're in use)
That’s where tls-client shines: it mimics browser fingerprint TLS handshakes, and can be used to bypass Cloudflare or JavaScript bot detection systems.
✅ Solution Using async_tls_client
Let’s go step-by-step with:
Installing and importing the required library
Grabbing hidden inputs (common in ASPX apps using ViewState)
Posting with correct headers, cookies, and form data
Parsing the resulting HTML
🛠️ 1. Install tls-client
bash
pip install async-tls-client
🔧 2. Code Sample (Async TLS Client Scraper)
python
import asyncio
from tls_client import Session
from bs4 import BeautifulSoup
import pandas as pd
URL = "https://websurrogates.nycourts.gov/File/FileSearch"
async def get_search_results():
# Create session
session = Session(client_identifier="chrome_120")
# Step 1: GET the search form
response = session.get(URL, headers={
"User-Agent": session.get_client_hello()["user_agent"]
})
soup = BeautifulSoup(response.text, "html.parser")
# ASP.NET web forms often use hidden fields
viewstate = soup.find('input', {'name': '__VIEWSTATE'})['value']
eventvalidation = soup.find('input', {'name': '__EVENTVALIDATION'})['value']
viewstategenerator = soup.find('input', {'name': '__VIEWSTATEGENERATOR'})['value']
# Step 2: Define your POST data when submitting the form
data = {
'__VIEWSTATE': viewstate,
'__EVENTVALIDATION': eventvalidation,
'__VIEWSTATEGENERATOR': viewstategenerator,
'ddlCourt': '332', # Kings County Surrogate's Court (get via dev tools)
'ddlProceedingType': 'A', # ADMINISTRATION PETITION
'txtFileDateFrom': '04/01/2025',
'txtFileDateTo': '04/30/2025',
'btnSearch': 'Search',
}
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Origin": "https://websurrogates.nycourts.gov",
"Referer": URL,
"User-Agent": session.get_client_hello()["user_agent"],
}
# Step 3: Send POST request to get results
post_url = "https://websurrogates.nycourts.gov/File/FileSearch"
result = session.post(post_url, data=data, headers=headers)
# Step 4: Parse resulting search page
soup = BeautifulSoup(result.text, "html.parser")
table = soup.find("table", {"id": "NameResultsTable"})
if table:
df = pd.read_html(str(table))[0]
df = df[["File #", "File Date"]]
print(df)
else:
print("No results found or failed to render table.")
asyncio.run(get_search_results())
✅ What This Does:
Uses tls-client's Session to mimic a Chrome browser TLS/JA3 signature
Loads the form and scrapes __VIEWSTATE, __EVENTVALIDATION (required in ASP.NET apps)
Prepares and submits the POST search request including required fields
Parses and prints a pandas DataFrame from the table ID "NameResultsTable"
🪪 How to Find ddlCourt and ddlProceedingType Values?