<commit_before>#!/usr/bin/env python
from bs4 import BeautifulSoup
import urllib

site_content = urllib.urlopen('https://aws.amazon.com/ec2/instance-types/').read()
soup = BeautifulSoup(site_content, 'lxml')
aws_tables = soup.find_all("div", {"class": "aws-table"});

for table_div in aws_tables:
    trs = table_div.find('table').tbody.find_all('tr')
    for tr in trs:
        tds = tr.find_all('td')
        rng = len(tds)
        line = ''
        if rng > 0:
            for i in range(0, rng):
                if i > 0:
                    line += ', '
                line += tds[i].get_text().strip()
            print(line)
    print('\n')<commit_msg>Fix a unicode bug when printing EC2 instance types on Windows machines<commit_after>#!/usr/bin/env python
from bs4 import BeautifulSoup
import urllib
import sys
import codecs

# Change encoding to fix a bug on windows
sys.stdout = codecs.getwriter("iso-8859-1")(sys.stdout, 'xmlcharrefreplace')

# Download a copy of the EC2 Instance Types from Amazon and scrape the content
site_content = urllib.urlopen('https://aws.amazon.com/ec2/instance-types/').read()
soup = BeautifulSoup(site_content, 'lxml')
aws_tables = soup.find_all("div", {"class": "aws-table"});

for table_div in aws_tables:
    trs = table_div.find('table').tbody.find_all('tr')
    for tr in trs:
        tds = tr.find_all('td')
        rng = len(tds)
        line = ''
        if rng > 0:
            for i in range(0, rng):
                if i > 0:
                    line += ', '
                line += tds[i].get_text().strip()
            print(line)
    print('\n')
{'fraction_non_alphanumeric': 0.1405371642723298, 'fraction_numerical': 0.010618363522798251, 'mean_word_length': 2.482608695652174, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1651897', 'n_tokens_mistral': 547, 'n_tokens_neox': 530, 'n_words': 135}