import requests
import feedparser
import praw
r = praw.Reddit('/r/jailbreak package description bot')
r.login("username","password")
            
def checkTweak(packageName):        
    response = requests.post("http://planet-iphones.com/cydia/feed/name/" + packageName)
    feed = feedparser.parse( response.text )
    for item in feed[ "items" ]:
        title = item[ "title" ]
        if title.lower() == packageName:
            return True
        else:
            return False
    
def getTweak(packageName):        
    response = requests.post("http://planet-iphones.com/cydia/feed/name/" + packageName)
    feed = feedparser.parse( response.text )
    for item in feed[ "items" ]:
        title = item[ "title" ]
        if title.lower() == packageName:
            link = str(item[ "link" ])
            descrip = str(item[ "description" ])
            link = "http://cydia.saurik.com/package/" + link.replace("http://planet-iphones.com/cydia/id/", "")
            return link, descrip
while True:
    subreddit = r.get_subreddit('jailbreak')
    for submission in subreddit.get_new(limit=25):
        obj = open('seen_posts.txt', 'ab+')
        if submission.id not in open("seen_posts.txt").read():
            title = submission.title
            for words in title.split(" "):
                if checkTweak(words.lower()):
                    link, descrip = getTweak(words.lower())
                    submission.add_comment("The following is short description and link to the tweak mentioned in this post: \n\n Title: [" + words +"](" + link + ") \n\nDescription: " + descrip + " \n\nCreated by healdb. This bot uses http://planet-iphones.com to find its information, and therefore makes no guarantees on it's accuracy")
                    print "Found post and commented, link: " + submission.permalink
        obj.write(submission.id)
        obj.close()

@@ -39,16 +39,47 @@
 rt praw%0A
+from bs4 import BeautifulSoup%0A%0A
 r = praw
@@ -157,28 +157,248 @@
 sword%22)%0A
-            
+%0Adef checkType(link):%0A    response = requests.post(link)%0A    soup = BeautifulSoup(response.text)%0A    tag= soup.find(id=%22section%22)%0A    type = str(tag.string)%0A    if type == %22Tweaks%22:%0A        return True%0A    else:%0A        return False
 %0Adef che
@@ -1210,16 +1210,52 @@
 /%22, %22%22)%0A
+            if checkType(link):%0A    
         

Use BS to determine if the package is a tweak