Hi, I'm trying to learn Python and I thought I'd mess around with praw. When creating a Reddit object, the format is r = praw.Reddit(user_agent = 'example') """this is what i saw on the praw docs"""
My question is: What is user_agent, and should I use the String 'example' when I make a Reddit object? The praw docs make it seem important: "NEVER lie about your user-agent. This includes spoofing popular browsers and spoofing other bots. We will ban liars with extreme prejudice."
So what should my user_agent be?
» pip install praw
Building a praw bot. Would appreciate it if you guys could answer a few questions for me
Tutorial I'm following: https://www.pythonforengineers.com/build-a-reddit-bot-part-1/
In the praw.ini file, I had to list the user agent for the bot. I'm familiar with what a user agent is in general (an identifier for your browser and system in an http request). However, the tutorial I'm following above says,
Libraries like Python’s urllib are severely restricted by Reddit to prevent abuse. Reddit recommends you use your own special user agent, and that’s what we’ll do.
Why is urllib restricted by Reddit and why is it recommended I use a special user agent? Plus, wouldn't this be considered user agent spoofing?
Edit: What does reddit even mean by special user agent? Does it mean I have to create a unique identifier for my api client? Also, isnt there a way to make a custom user agent in urllib? Hypothetically if I were to use urllib for my bot how would reddit even know if I changed the user agent?
My PRAW instance is authorised to scrape data from a quarantined sub. However, my application depends on requests' GET function to view the .json data for each post, e.g.,
req = requests.get(URL, headers={
"User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36"
}
...where URL is some Reddit post's URL with ".json" appended.
How do I structure the "User-agent" header to contain the user information I'm passing into my Reddit instance of PRAW so that I avoid a Forbidden 403?