Я пытаюсь очистить сайты электронной коммерции в моей базе данных для сегментации пользователей по внешнему виду определенного ключевого слова.
Я использую библиотеку Google Colab и Pandas с библиотекой запросов.
Тем не менее, это так медленно. Он очищает 100 сайтов за 293 секунды.
Есть ли способ улучшить его?
вот мой код
start = timeit.default_timer()
for url in Account["url"][:100]:
try:
url = "https://" + url
page = requests.get(url)
contents = page.content
if len(re.findall(key4, contents)) < 1 and len(re.findall(key3, contents)) > 0:
if len(re.findall(key1, contents)) > 50 or len(re.findall(key2, contents)) > 50:
products_found = len(re.findall(key1, contents))
collection_found = len(re.findall(key2, contents))
shopping_stores_df = shopping_stores_df.append({'url': url, 'products': products_found, 'collections': collection_found}, ignore_index=True)
shopping_stores_df.loc[shopping_stores_df['url'] == url, ['ranking', 'people', 'emails', 'tel']] = df.loc[df['Location on Site'] == url[8:], ['Alexa', 'People', 'Emails', 'Telephones']].values
except: pass
stop = timeit.default_timer()
print('Execution time:', start-stop)
shopping_stores_df
Спасибо!