This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
import time | |
import pandas as pd | |
import numpy as np | |
import re | |
# Scrape one category # Travel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for c in range(1,11): | |
print("http://books.toscrape.com/catalogue/category/books_1/page-{}.html".format(c)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
import time | |
import pandas as pd | |
import numpy as np | |
import re | |
def StarConversion(value): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
import time | |
import pandas as pd | |
import numpy as np | |
import re | |
#Set up the path to the chrome driver | |
PATH = "/home/kiprono/chromedriver" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multiple_elements = driver.find_elements_by_class_name("container1") | |
for element in multiple_elements: | |
print(element.text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
import time | |
PATH = "./chromedriver" | |
driver = webdriver.Chrome(PATH) | |
driver.get(url="file:///home/kiprono/Desktop/untitled.html") | |
print("Element identified by id:",driver.find_element_by_id("JDCf").text) | |
print("Element identified by class:",driver.find_element_by_class_name("container1").text) | |
print("Element identified by class:",driver.find_element_by_class_name("col4").text) | |
print("Element identified by tag name:",driver.find_element_by_tag_name("h1").text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
import time | |
PATH = "./chromedriver" | |
driver = webdriver.Chrome(PATH) | |
driver.get(url="file:///home/kiprono/Desktop/untitled.html") | |
time.sleep(5) | |
driver.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#most common words | |
print("Most Common emojis used (Me)") | |
common_emojis_me = Counter(myself_emojis).most_common() | |
common_emojis_her = Counter(mylove_emojis).most_common() | |
emojis_me = [] | |
count_me = [] | |
for index, item in enumerate(common_emojis_me): | |
if index == 5: | |
break | |
print(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import emoji | |
def extract_emojis(str): | |
return ''.join(c for c in str if c in emoji.UNICODE_EMOJI) | |
mylove_emojis = [] | |
myself_emojis = [] | |
for i in range(len(df)): | |
if "My Wife, I LOVE YOU" in df.at[i,"Sender"]: | |
message = df.at[i,"Message"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Her most common words | |
common_her = pd.DataFrame(common_count_her,mylove_common,columns=["Her"]).sort_values(by="Her") | |
plt.figure(figsize=(8,6)) | |
plt.barh(common_her.index, common_her["Her"], align='center', alpha=0.8,color="pink") | |
plt.yticks(mylove_common,mylove_common) | |
plt.xlabel('Words') | |
plt.title('Most Used Words(My Love)') | |
plt.show() | |
# Words I commonly used |
NewerOlder