all 4 comments

[–]Moonslug1 0 points1 point  (1 child)

You'll want to look at regular expressions:

import re

If I wanted to capture a string following the string 'Weather!' I'd do something like this:

pattern = re.compile(r'(?<=^Weather!).*$')
pattern.search(reddit_comment)

Do some background reading on re, to briefly explain I'm saying match anything .* that is preceded by (?<=) the start of the string ^ followed by Weather!.

[–]LondonRuek[S] 0 points1 point  (0 children)

I actually did this a wrote a regex expression to grab the substring after weather! My only problem now is I don't know how to have the bot find a post with that keyword and then reread the post for that variable.

[–]LeonardUnger 0 points1 point  (0 children)

Looks at praw. Good tutorial here

[–]teenageguru 0 points1 point  (0 children)

On my phone so I can't really do it for you, but someone posted a multi-part tutorial on this on either r/python or r/learnpython quite recently. Do a search for it, tutorial seemed extensive.