# This code block demonstrates how to search for PDF files containing Python interview questions and answers using Google Search API.
from googlesearch import search
# Define the search query
query = "python interview questions and answers filetype:pdf"
# Perform the search
search_results = search(query, num_results=1) # Only retrieve the top 1 search result
# Download the PDF file
import requests
pdf_url = next(search_results)
response = requests.get(pdf_url)
# Save the PDF file locally
with open("python_interview_questions.pdf", "wb") as f:
f.write(response.content)
print("PDF file downloaded successfully.")