Here's a code snippet in Python that uses requests and Beautiful Soup libraries to scrape the latest headline from the New York Times website:
main.py253 chars11 lines
Note: The class name css-1vvhd4r esl82me1
may change over time as the website gets updated. So before running the code, it's recommended to inspect the HTML code of the website and update the class name accordingly.
gistlibby LogSnag