To get the latest post from a Reddit account in C#, you will need to use the Reddit API and a HTTP client such as HttpClient. Here are the steps:
Get an access token for the Reddit API by following the instructions on https://www.reddit.com/dev/api/.
Use HttpClient to make an HTTP GET request to the Reddit API endpoint that returns the latest post of a user. The endpoint is https://oauth.reddit.com/user/{username}/submitted.json?limit=1.
Deserialize the JSON response into a C# object using a JSON serializer such as Newtonsoft.Json.
Access the properties of the C# object to get the data of the latest post.
Here is some sample code to achieve this:
main.cs982 chars33 lines
You can call this method with the access token and username of the Reddit account you want to scrape:
main.cs341 chars9 lines
This will print the data of the latest post in the console.
gistlibby LogSnag