def comentar_sorteio(self, repetir=False):
        driver = self.driver
        time.sleep(30)
        driver.get(url)

        try:
            csv = CSVHandler()
            if escolha == 1:
                comentarios = csv.open_csv("P:\\Python\\Programas\\BOT_Instagram\\planilhas\\111.csv")
            elif escolha == 2:
                comentarios = csv.open_csv("P:\\Python\\Programas\\BOT_Instagram\\planilhas\\2.csv")
            else:
                comentarios = csv.open_csv("P:\\Python\\Programas\\BOT_Instagram\\planilhas\\333normal.csv")
            driver.find_element_by_class_name('Ypffh').click()
            campo_comentario = driver.find_element_by_class_name('Ypffh')
            time.sleep(random.randint(2, 5))
            self.digite_como_uma_pessoa(
                random.choice(comentarios), campo_comentario)
            print(campo_comentario)
            time.sleep(random.randint(30, 40))
            driver.find_element_by_xpath(
                "//button[contains(text(), 'Publicar')]").click()
            time.sleep(60)
        except Exception as e:
            print(e)
            time.sleep(5)
예제 #2
0
def main():
    all_people_query_set = PeopleQuerySet(foreign_keys={'species': SpeciesQuerySet()}).get_all()
    top_10_people_by_appearances = all_people_query_set.order_by('films_count')[0:10]
    top_10_people_by_appearances_order_by_height = top_10_people_by_appearances.order_by('height')
    top_10_people_by_appearances_order_by_height.resolve_foreign_keys()

    csv_file = CSVHandler(items=top_10_people_by_appearances_order_by_height.items,
                          fields={'name': 'name', 'species': 'species', 'height': 'height',
                                  'appearances': 'films_count'})

    HTTPBin().send_file(file=csv_file.file_path)
예제 #3
0
def doesCommitteeExist(committee):
    """
    Args:
        committee: list of information about a committee.

    Returns:
        boolean which is true if and only if the committee
        is in the CSV file.
    """
    emailFile = CSVHandler(EMAIL_FILE_LOCATION)
    contents = emailFile.read()
    isInList = False
    print(committee)
    for x in contents:
        print(x)
        if (x[0] == committee[0]):
            isInList = True
    return isInList
class TestCSVHandler:
    testFile = CSVHandler(TEST_FILE_LOCATION)

    def testOpenFile(self):
        assert self.testFile != None

    def testRead(self):
        contents = self.testFile.read()
        print(contents)

        assert contents == TEST_FILE_CONTENTS

    def testWrite(self):
        self.testFile.write([])
        contents = self.testFile.read()
        assert contents == []

        self.testFile.write(TEST_FILE_CONTENTS)
        contents = self.testFile.read()
        assert contents == TEST_FILE_CONTENTS
예제 #5
0
    def test_write_csv_file(self, mock_csv):
        class DummyStructure:
            def __init__(self, text1, value1, text2):
                self.text1 = text1
                self.text2 = text2
                self.value1 = value1

        tmp_file = TestFileContent(content='')
        csv = CSVHandler(items=[DummyStructure('text1', 2, 'text2')],
                         fields={'header_text1': 'text1', 'header_value1': 'value1', 'header_text2': 'text2'},
                         file_path=tmp_file.filename)

        mock_csv.writer.assert_called_once()
        calls = [call().writerow({'header_text1': '', 'header_value1': '', 'header_text2': ''}.keys()),
                 call().writerow(['text1', '2', 'text2'])]
        mock_csv.writer.assert_has_calls(calls)
        self.assertEqual(mock_csv.writer.call_args.args[0].name, tmp_file.filename)
        self.assertEqual(mock_csv.writer.call_args.kwargs['delimiter'], ',')
        self.assertEqual(mock_csv.writer.call_args.kwargs['quotechar'], '"')
        self.assertEqual(mock_csv.writer.call_args.kwargs['quoting'], mock_csv.QUOTE_MINIMAL)
예제 #6
0
 def testNumbersAreRoughlyCorrect(self):
     emailFile = CSVHandler(EMAIL_FILE_LOCATION)
     contents = emailFile.read()
     socCount = len(contents)
     assert socCount > 380
     assert socCount < 400
예제 #7
0

app = Flask(__name__)
# 扩展在创建应用实例时初始化,一种方式是将应用实例传入构造函数
bootstrap = Bootstrap(app)

# 商品ID与回调函数
# 按销量选了三个牌子的,1 小米 2 公牛 3 良品 4 飞利浦
param_list = [['4354506', 'fetchJSON_comment98vv3810'],
                ['492036', 'fetchJSON_comment98vv203899'],
                ['5342704', 'fetchJSON_comment98vv774'],
              ['4130061', 'fetchJSON_comment98vv4666'],
              ]

# init
csv_handler = CSVHandler()
part = None
w2v = W2V()
his = {}

# 。。。
graph = tf.get_default_graph()


@app.route('/')
def index():
    return render_template('index_bootstrap.html')


@app.route('/crawler')
def crawler():
예제 #8
0
 def __init__(self, lstm_model, csv_path):
     self.counter = 0
     self.csv_handler = CSVHandler(csv_path)
     self.lstm_model = lstm_model
예제 #9
0
 def __init__(self, access_token, account_id, csv_path):
     super().__init__(access_token, account_id)
     self.csv_handler = CSVHandler(csv_path)
    emailContainer = pageSoup.find('div', class_="outlet__header--contact t__def-bl--pri contact__align mgn__t--1 mgn__b--1")
    email = ""
    if emailContainer != None:
        email = emailContainer.find('a').text

    return [name, email]

def getAllInfo(links):
    result = []

    # Setup for the progess meter.
    completion = 0
    step = 100/len(links)

    # Get the page info from each link.
    for link in links:
        currInfo = extractSocietyInfo(link)
        result.append(currInfo)

        # Advance and print out how far through the program is.
        completion += step
        print("{}% done".format(round(completion)))
    return result

# Get society info.
societyUrls = findSocietyPages()
socInfo = getAllInfo(societyUrls)

# Write it all to a CSV.
testFile = CSVHandler(EMAIL_FILE_LOCATION)
testFile.write(socInfo)
예제 #11
0
 def test_no_fields_provided(self):
     with self.assertRaises(CSVHandler.MissingCSVFields):
         CSVHandler(items=[])