Passing callback to @browser() function #20
Unanswered
sonnguyendjv
asked this question in
Q&A
Replies: 1 comment
-
Pass as metadata from botasaurus import *
@request
def scrape_heading_task(request: AntiDetectRequests, data, callback):
# Navigate to the Omkar Cloud website
soup = request.bs4("https://www.omkar.cloud/")
# Retrieve the heading element's text
heading = soup.find('h1').get_text()
callback()
# Save the data as a JSON file in output/scrape_heading_task.json
return {
"heading": heading
}
if __name__ == "__main__":
# Initiate the web scraping task
callback = lambda: print("Hello from callback!")
scrape_heading_task(metadata=callback) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey guys,
I am new to Python
Please guide me how can I pass callback function to scrape_heading_task()
Beta Was this translation helpful? Give feedback.
All reactions