<commit_before>import requests
import re
import logging
from bs4 import BeautifulSoup
_r_learnprogramming_url = re.compile(r'http://(www.)?reddit.com/r/learnprogramming')

def downloadRedditUrl(url):
    logging.debug(u"Downloading url: {}".format(url))
    assert _r_learnprogramming_url.match(url)
    headers = { 'User-Agent': 'SearchingReddit bot version 0.1'}
    r = requests.get(url, headers=headers)
    if r.status_code != 200:
        raise Exception("Non-OK status code: {}".format(r.status_code))
    return r.text

def parseRedditPost(html):
    bs = BeautifulSoup(html)
    return bs.select('div.usertext-body')[1].text<commit_msg>Speedup parseRedditPost by about 10%<commit_after>import requests
import re
import logging
from bs4 import BeautifulSoup, SoupStrainer
_r_learnprogramming_url = re.compile(r'http://(www.)?reddit.com/r/learnprogramming')

def downloadRedditUrl(url):
    logging.debug(u"Downloading url: {}".format(url))
    assert _r_learnprogramming_url.match(url)
    headers = { 'User-Agent': 'SearchingReddit bot version 0.1'}
    r = requests.get(url, headers=headers)
    if r.status_code != 200:
        raise Exception("Non-OK status code: {}".format(r.status_code))
    return r.text

_only_div_usertext_body = SoupStrainer("div", {'class': lambda L: L is not None and 'usertext-body' in L.split()})

def parseRedditPost(html):
    bs = BeautifulSoup(html,parse_only=_only_div_usertext_body)
    return bs.select('div.usertext-body')[1].text
{'fraction_non_alphanumeric': 0.12990527740189445, 'fraction_numerical': 0.010825439783491205, 'mean_word_length': 4.9397590361445785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5019468', 'n_tokens_mistral': 508, 'n_tokens_neox': 488, 'n_words': 105}