Skip to content

Commit 02d8389

Browse files
authored
Merge pull request #3 from KOBeerose/main
Merging stuff
2 parents 0811a7f + 6a2a65b commit 02d8389

28 files changed

Lines changed: 21766 additions & 959 deletions

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# .gitignore tells git which files (or patterns) it should ignore. It's usually used to avoid
2+
# committing transient files from your working directory that aren't useful to other collaborators,
3+
# such as compilation products, temporary files IDEs create, etc.
4+
.ipynb_checkpoints
5+
*/.ipynb_checkpoints/*
6+
Information.txt
7+
*.csv
8+
!3-Exploratory Data Analysis/datadyalna.csv
3.92 MB
Binary file not shown.
File renamed without changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
# first of all of should create your own Information.txt file and DELETE THIS ONE OF if you wanna push your code to GitHub
3+
# Explaination: there a .gitignore file in which we put all the file and directories that we don't wanna push to GitHub and you definitely don't want your password to be public to anyone.
4+
# So we can add save our info locally in Infomation.txt file and add it to .gitignore file so that git will ignore it (BE CAREFULL OF SPELLING!)
5+
# !!! you can change the order but make sure to keep this format or change the code to match it otherwise !!!
6+
7+
8+
url: https://www.facebook.com/
9+
10+
email: bot@mail.ai
11+
12+
password: bot@mail.ai
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
#importing all the necessary libaries
23
from selenium import webdriver
34
from selenium.common.exceptions import TimeoutException
45
from selenium.webdriver.common.by import By
@@ -10,6 +11,7 @@ class FacebookCrawler:
1011
LOGIN_URL = 'https://www.facebook.com/login.php?login_attempt=1&lwv=111'
1112

1213
def __init__(self, login, password):
14+
# defining the webdriver and config btw this code will be almost the same in all of your selenium scripts
1315
chrome_options = webdriver.ChromeOptions()
1416
prefs = {"profile.default_content_setting_values.notifications": 2}
1517
chrome_options.add_experimental_option("prefs", prefs)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#importing all the necessary libaries
2+
from selenium import webdriver
3+
from selenium.webdriver.chrome.options import Options
4+
import time
5+
import string
6+
7+
url = email = password = ''
8+
# defining the webdriver and config btw this code will be almost the same in all of your selenium scripts
9+
chrome_options = webdriver.ChromeOptions()
10+
11+
# !!! blocking browser notifications !!!
12+
prefs = {"profile.default_content_setting_values.notifications" : 2}
13+
chrome_options.add_experimental_option("prefs", prefs)
14+
15+
# starting in maximized window
16+
chrome_options.add_argument("start-maximized")
17+
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path="C:\\Users\\taha_\\Downloads\\chromedriver_win32\\chromedriver.exe")
18+
19+
20+
# this function gets the user info and save them in variables
21+
def get_info(filename):
22+
elem_list=["url","email","password"] # list of expressions preceding the user info
23+
with open(filename, 'r') as read_obj:
24+
for line in read_obj:
25+
for elem in elem_list: # Get the value after an expression occurrence
26+
if elem in line:
27+
# save the value in a variable named according to the expression preceding it
28+
globals()[elem] = line.partition(elem+": ")[2].translate({ord(c): None for c in string.whitespace})
29+
30+
# getting values of the user information
31+
get_info("C:\\Users\\taha_\\OneDrive - ine.inpt.ma\\Coding\\Data Science\\Data-Science-Cell-Training\\Data Collection\\scripts\\Information.txt")
32+
print(url, email, password)
33+
driver.get(url)
34+
35+
mail = driver.find_element_by_name("email")
36+
mail.send_keys(email)
37+
38+
passwrd = driver.find_element_by_name("pass")
39+
passwrd.send_keys(password)
40+
41+
42+
log = driver.find_element_by_name("login")
43+
log.click()
44+
45+
time.sleep(.5)
46+
47+
48+
driver.get("http://facebook.com/profile.php")
49+
50+
time.sleep(.5)
51+
52+
'''l2= driver.find_element_by_xpath("//div[@class='sej5wr8e']")
53+
driver.execute_script("arguments[0].scrollIntoView(true);", l2)
54+
time.sleep(0.5)
55+
56+
button = driver.find_element_by_xpath("//div[@class='rq0escxv l9j0dhe7 du4w35lb j83agx80 pfnyh3mw i1fnvgqd gs1a9yip owycx6da btwxx1t3']")
57+
button.click()'''
58+
59+
driver.get(driver.current_url+"friends")
60+
61+
# Complete the follwing script to get data about your facebook friends
62+
# driver.quit()
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import pandas as pd
22

3-
df = pd.read_html('https://data-science-cell.netlify.app/', )
3+
df = pd.read_html('https://www.investing.com/crypto/bitcoin/historical-data', )
44
df = df[0]
55

66
# droping some unncessary data
7-
df.drop(df.columns[-1], axis=1, inplace=True)
7+
"""df.drop(df.columns[-1], axis=1, inplace=True)
88
99
df.drop(df[df['column'] == 'value'], axis=1, inplace=True)
1010
@@ -13,6 +13,7 @@
1313
print(df)
1414
1515
# saving Dataframe to a csv file
16-
df.to_csv('data-cell-memebers.csv', index=False)
16+
df.to_csv('data-cell-memebers.csv', index=False)"""
1717

1818

19+
print(df)

0 commit comments

Comments
 (0)