Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
HillaShx committed Apr 27, 2023
2 parents 96575d8 + 3b04d9f commit b423ac5
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 3 deletions.
8 changes: 8 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#setting up the keys
CONSUMER_KEY = "vtvXcGs4JrhZiCpW1To8yBjd1"
CONSUMER_SECRET ="RTejOkHenr5KacpZFaWT5MpBBfUMg1rXy3KJKITxGAd5Zsjv1N"
ACCESS_TOKEN ="701551467287683072-isydleAT61b8R67aMBrMA0LuWlKvfVt"
ACCESS_TOKEN_SECRET="pvPSolNaLDVbfn1ZFhdLdV7k76Cs3n2L4CysND0OzXTqg"

# Authenticate to Twitter
bearer_token = "AAAAAAAAAAAAAAAAAAAAAGUhnAEAAAAAc4qUjyiCkMKCCIjVVZTqbzqHTGk%3DV8bF2bnYME54pvSnoriLHe3zIWiLVKHQZwHL5PDdCPuMF8rlFy"
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ def health_test():
app.include_router(interface_router)

if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
uvicorn.run(app, host="0.0.0.0", port=8000)
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jaraco.classes==3.2.3
keyring==23.13.1
lxml==4.9.2
more-itertools==9.1.0
numpy==1.24.3
oauthlib==3.2.2
pandas==2.0.1
parse==1.19.0
premailer==3.10.0
pydantic==1.10.7
Expand All @@ -36,11 +39,13 @@ PyYAML==6.0
regex==2023.3.23
requests==2.29.0
requests-html==0.10.0
requests-oauthlib==1.3.1
six==1.16.0
sniffio==1.3.0
soupsieve==2.4.1
starlette==0.26.1
tqdm==4.65.0
tweepy==4.14.0
typing_extensions==4.5.0
tzdata==2023.3
tzlocal==4.3
Expand Down
29 changes: 27 additions & 2 deletions routers/scraping.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from fastapi import APIRouter
from facebook_scraper import get_posts
from datetime import datetime

import pandas as pd
import tweepy
from facebook_scraper import get_posts
from fastapi import APIRouter

import config
from DTO.post import FacebookPost
from services.csv_helper import CSVWriter

Expand Down Expand Up @@ -43,3 +47,24 @@ async def scrape_facebook():
csv_writer = CSVWriter(FacebookPost)
csv_writer.write(posts, f"storage/facebook/{datetime.date(datetime.now())}.csv")
return posts


@router.get("/twitter")
async def scrape_twitter():
ids = read_ids_from_file("twitter_ids_for_scraping.txt")
df = pd.DataFrame(columns=["id", "username", "text", "created_at", "lang", "possibly_sensitive"])
client = tweepy.Client(bearer_token=config.bearer_token)
for id in ids:
new_tweets = client.get_users_tweets(id, tweet_fields=['id', 'text', 'possibly_sensitive', 'lang', 'created_at'])
user = client.get_user(id=id)
for tweet in new_tweets.data:
l = {
"id": tweet.id,
"username": user.data.username,
"text": tweet.text,
"created_at": tweet.created_at,
"lang": "he" if tweet.lang == "iw" else tweet.lang,
"possibly_sensitive": tweet.possibly_sensitive,
}
df = pd.concat([df, pd.DataFrame([l])], ignore_index=True)
return
37 changes: 37 additions & 0 deletions storage/twitter/tweets.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
id,username,text,created_at,lang,possibly_sensitive
1651599449540403201,adhayeiladim,מקור: https://t.co/Rn92SqDLIL,2023-04-27 14:49:28+00:00,he,False
1651599387129249792,adhayeiladim,"מעגל הנרטיב סביב ״ילדים טרנס״ כפי שהוגדר ע״י ד״ר ג׳רמי שו בטוויטר (מקור בתגובות), תורגם על ידנו.
נשמח לשיתופים בכל הפלטפורמות!

Credit: @JeremyShawMD https://t.co/VzGvPMICoF",2023-04-27 14:49:13+00:00,he,False
1651596058793738242,adhayeiladim,"איגוד הפסיכולוגים מתעלם מהמחקרים הכי עדכניים, ומשינוי מדיניות במדינות מתקדמות כמו בריטניה, שבדיה, פינלד ונורבגיה שהפסיקו בטיפולי ""התאמה מגדרית"" בילדים.
מוזמנים להשכיל פה: https://t.co/dBHvCXgzTN https://t.co/wMsQPLfxbN",2023-04-27 14:36:00+00:00,he,False
1651512464633102337,adhayeiladim,"RT @nfsgalibh: משקרים לכל הילדים שלנו. ולא צריך להתלבט למי להאמין כי עיקור, סירוס, והפיכת ילדים בראים לחולים כרוניים לא יכולים להיות פתרון…",2023-04-27 09:03:49+00:00,he,False
1651512133765431301,adhayeiladim,@shakedmiriam למה העירייה מממנת שעת סיפור בדראג? יש להם אג'נדה ברורה מאוד,2023-04-27 09:02:30+00:00,he,False
1651511989313708041,adhayeiladim,@shakedmiriam @TelAvivYafo @Ron_Huldai,2023-04-27 09:01:56+00:00,qam,False
1651510908512874496,adhayeiladim,"@cherderol @shakedmiriam @eBJg2WKX0UQEFG3 היא עושה הרבה יותר גרוע מרק לקיחת צד פוליטי.
האגודה דוחפות אג'נדות בבתי ספר, מממנת עורכי דין כדי להתריד את מנגדיה, ודוחפת ילדים לסירוס ופגיעה. יש לנו הרבה ציוצים על הנעשה, במיוחד סירוס ונזק בלתי הפיך בילדים הומוסקסואלים בשביל לקרוא להם ""טרנס"".",2023-04-27 08:57:38+00:00,he,False
1651274583192879131,adhayeiladim,"RT @ProgressivismE: הם מכחישים שוב ושוב שהם מנרמלים פדופיליה, עד יום אחד הם חושפים את הדגל החדש ל""נטיה המינית החדשה""

ויש גם שם חדש! כי חיי…",2023-04-26 17:18:34+00:00,he,False
1651215299793010688,adhayeiladim,"מלכת דראג ""סוזי בום"" מסביר שמחפש להופיע בפני הרבה ילדים ביוטיוב.
למה?
שיעזוב את הילדים בשקט. שמרו על הילדים שלכם, תרחיקו אותם מהרוע הזה. https://t.co/CCHWD06fSk",2023-04-26 13:23:00+00:00,he,False
1651026967263686662,adhayeiladim,"@asherisraeli עובדה שזה מתחיל להיות לא חוקי בארה""ב בפרק זמח מאוד קצר. וארופה גם.
זה משתנה מהר מאוד בחו""ל",2023-04-26 00:54:38+00:00,he,False
1651445599030353923,shirlief,@DanielGinat ברור,2023-04-27 04:38:07+00:00,he,False
1651256321843265538,shirlief,"RT @adhayiladim: מלכת דראג ""סוזי בום"" מסביר שמחפש להופיע בפני הרבה ילדים ביוטיוב.
למה?
שיעזוב את הילדים בשקט. שמרו על הילדים שלכם, תרחיקו…",2023-04-26 16:06:00+00:00,he,False
1651128225269964803,shirlief,"RT @TransJusticeOrg: ""Only 1% detransition""... doesn't seem to hold up these days, does it? #DetransAwarenessDay #IAmDetrans https://t.co/E…",2023-04-26 07:37:00+00:00,en,False
1651070519712645120,shirlief,@OliLondonTV They don’t learn ah? using this dude promoting female products is not so good for business #boycottmaybelline,2023-04-26 03:47:41+00:00,en,False
1651069950981730306,shirlief,@HollyBriden @OliLondonTV Him,2023-04-26 03:45:26+00:00,und,False
1651069626015526913,shirlief,@ClownWorld_ Didn’t they learn that using this dude for modelling women’s product is bad for business? 🤦🏻‍♀️ #boycottmaybelline,2023-04-26 03:44:08+00:00,en,False
1650973432803147777,shirlief,"RT @NotScottNewgent: One after another, after another.

Young adults are NOT doing well after medically transitioning in childhood.

Mains…",2023-04-25 21:21:54+00:00,en,False
1650972385078648832,shirlief,@OfTheFutureArt @VonAlawon I’m happy to read that your relationship with your mom healed .. my daughter is now a year on T and has cut off all contact with me. I pray each day that one day our relationship will heal as well with min damages to her body,2023-04-25 21:17:44+00:00,en,False
1650763139619647488,shirlief,@sleepymammabear Celebrities are working for the agenda and the CIA,2023-04-25 07:26:16+00:00,en,False
1650733720746196992,shirlief,RT @SpartaJustice: RULERS OF OUR WORLD: The Committee of 300 is a small group of insidious people who control all aspects of our world. Thr…,2023-04-25 05:29:22+00:00,en,False
3 changes: 3 additions & 0 deletions twitter_ids_for_scraping.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1625190438322769925
45303271
1343657485677309952

0 comments on commit b423ac5

Please sign in to comment.