add backend for twitter bookmarks archive
This commit is contained in:
@@ -41,6 +41,7 @@ class Twitter_Scraper:
|
|||||||
scrape_username=None,
|
scrape_username=None,
|
||||||
scrape_hashtag=None,
|
scrape_hashtag=None,
|
||||||
scrape_query=None,
|
scrape_query=None,
|
||||||
|
scrape_bookmarks=False,
|
||||||
scrape_poster_details=False,
|
scrape_poster_details=False,
|
||||||
scrape_latest=True,
|
scrape_latest=True,
|
||||||
scrape_top=False,
|
scrape_top=False,
|
||||||
@@ -58,6 +59,7 @@ class Twitter_Scraper:
|
|||||||
"type": None,
|
"type": None,
|
||||||
"username": None,
|
"username": None,
|
||||||
"hashtag": None,
|
"hashtag": None,
|
||||||
|
"bookmarks": False,
|
||||||
"query": None,
|
"query": None,
|
||||||
"tab": None,
|
"tab": None,
|
||||||
"poster_details": False,
|
"poster_details": False,
|
||||||
@@ -72,6 +74,7 @@ class Twitter_Scraper:
|
|||||||
max_tweets,
|
max_tweets,
|
||||||
scrape_username,
|
scrape_username,
|
||||||
scrape_hashtag,
|
scrape_hashtag,
|
||||||
|
scrape_bookmarks,
|
||||||
scrape_query,
|
scrape_query,
|
||||||
scrape_latest,
|
scrape_latest,
|
||||||
scrape_top,
|
scrape_top,
|
||||||
@@ -83,6 +86,7 @@ class Twitter_Scraper:
|
|||||||
max_tweets=50,
|
max_tweets=50,
|
||||||
scrape_username=None,
|
scrape_username=None,
|
||||||
scrape_hashtag=None,
|
scrape_hashtag=None,
|
||||||
|
scrape_bookmarks=False,
|
||||||
scrape_query=None,
|
scrape_query=None,
|
||||||
scrape_latest=True,
|
scrape_latest=True,
|
||||||
scrape_top=False,
|
scrape_top=False,
|
||||||
@@ -99,6 +103,7 @@ class Twitter_Scraper:
|
|||||||
"hashtag": str(scrape_hashtag).replace("#", "")
|
"hashtag": str(scrape_hashtag).replace("#", "")
|
||||||
if scrape_hashtag is not None
|
if scrape_hashtag is not None
|
||||||
else None,
|
else None,
|
||||||
|
"bookmarks": scrape_bookmarks,
|
||||||
"query": scrape_query,
|
"query": scrape_query,
|
||||||
"tab": "Latest" if scrape_latest else "Top" if scrape_top else "Latest",
|
"tab": "Latest" if scrape_latest else "Top" if scrape_top else "Latest",
|
||||||
"poster_details": scrape_poster_details,
|
"poster_details": scrape_poster_details,
|
||||||
@@ -112,6 +117,9 @@ class Twitter_Scraper:
|
|||||||
elif scrape_hashtag is not None:
|
elif scrape_hashtag is not None:
|
||||||
self.scraper_details["type"] = "Hashtag"
|
self.scraper_details["type"] = "Hashtag"
|
||||||
self.router = self.go_to_hashtag
|
self.router = self.go_to_hashtag
|
||||||
|
elif scrape_bookmarks is not False:
|
||||||
|
self.scraper_details["type"] = "Bookmarks"
|
||||||
|
self.router = self.go_to_bookmarks
|
||||||
elif scrape_query is not None:
|
elif scrape_query is not None:
|
||||||
self.scraper_details["type"] = "Query"
|
self.scraper_details["type"] = "Query"
|
||||||
self.router = self.go_to_search
|
self.router = self.go_to_search
|
||||||
@@ -120,6 +128,8 @@ class Twitter_Scraper:
|
|||||||
self.router = self.go_to_home
|
self.router = self.go_to_home
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
print(134)
|
||||||
|
|
||||||
def _get_driver(
|
def _get_driver(
|
||||||
self,
|
self,
|
||||||
proxy=None,
|
proxy=None,
|
||||||
@@ -339,6 +349,21 @@ It may be due to the following:
|
|||||||
sleep(3)
|
sleep(3)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def go_to_bookmarks(self):
|
||||||
|
print("356")
|
||||||
|
if (
|
||||||
|
self.scraper_details["bookmarks"] is False
|
||||||
|
or self.scraper_details["bookmarks"] == ""
|
||||||
|
):
|
||||||
|
print("Bookmarks is not set.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
url = f"https://twitter..com/i/bookmarks"
|
||||||
|
|
||||||
|
self.driver.get(url)
|
||||||
|
sleep(3)
|
||||||
|
pass
|
||||||
|
|
||||||
def go_to_search(self):
|
def go_to_search(self):
|
||||||
if self.scraper_details["query"] is None or self.scraper_details["query"] == "":
|
if self.scraper_details["query"] is None or self.scraper_details["query"] == "":
|
||||||
print("Query is not set.")
|
print("Query is not set.")
|
||||||
@@ -378,6 +403,7 @@ It may be due to the following:
|
|||||||
no_tweets_limit=False,
|
no_tweets_limit=False,
|
||||||
scrape_username=None,
|
scrape_username=None,
|
||||||
scrape_hashtag=None,
|
scrape_hashtag=None,
|
||||||
|
scrape_bookmarks=False,
|
||||||
scrape_query=None,
|
scrape_query=None,
|
||||||
scrape_latest=True,
|
scrape_latest=True,
|
||||||
scrape_top=False,
|
scrape_top=False,
|
||||||
@@ -388,6 +414,7 @@ It may be due to the following:
|
|||||||
max_tweets,
|
max_tweets,
|
||||||
scrape_username,
|
scrape_username,
|
||||||
scrape_hashtag,
|
scrape_hashtag,
|
||||||
|
scrape_bookmarks,
|
||||||
scrape_query,
|
scrape_query,
|
||||||
scrape_latest,
|
scrape_latest,
|
||||||
scrape_top,
|
scrape_top,
|
||||||
@@ -409,6 +436,9 @@ It may be due to the following:
|
|||||||
self.scraper_details["tab"], self.scraper_details["hashtag"]
|
self.scraper_details["tab"], self.scraper_details["hashtag"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
elif self.scraper_details["type"] == "Bookmarks":
|
||||||
|
print(
|
||||||
|
"Scraping Tweets from @{} bookmarks...".format(self.scraper_details["username"]))
|
||||||
elif self.scraper_details["type"] == "Query":
|
elif self.scraper_details["type"] == "Query":
|
||||||
print(
|
print(
|
||||||
"Scraping {} Tweets from {} search...".format(
|
"Scraping {} Tweets from {} search...".format(
|
||||||
|
|||||||
Reference in New Issue
Block a user