Skip to content

Instantly share code, notes, and snippets.

@achadha235
Created March 6, 2023 21:39
Show Gist options
  • Select an option

  • Save achadha235/f55530e588464ad5ce05297b9f793f08 to your computer and use it in GitHub Desktop.

Select an option

Save achadha235/f55530e588464ad5ce05297b9f793f08 to your computer and use it in GitHub Desktop.
import { DateTime } from "luxon";
import { Page } from "puppeteer";
import { logger } from "./index";
import { sleep } from "./utils";
export async function goToEDFSearchPage(
page: Page,
start: string,
end: string
) {
try {
await page.goto("https://efdsearch.senate.gov/search/home/");
await page.waitForNetworkIdle();
logger.info("Setting form parameters...");
await page.click("#reportTypeLabelPtr");
const [startDate, endDate] = [
DateTime.fromISO(start).toFormat("dd/MM/yyyy"),
DateTime.fromISO(end).toFormat("dd/MM/yyyy"),
];
await page.type("#fromDate", startDate);
await page.type("#toDate", endDate);
await page.click("#searchForm > div > button");
await page.waitForNetworkIdle();
await page.click("#filedReports_length > label > select");
await page.select("#filedReports_length > label > select", "100"); // Show 100 results at once
await sleep(2000);
logger.info("Finding search results...");
} catch (error) {
await page.screenshot({ path: "./error.png", fullPage: true });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment