Commit 4cb87914 authored by andytnt's avatar andytnt Committed by Francesco Poldi

Fix Target profile infos are scraped at each round (#261)

* Fix json

* Added new data to meta

* Fix Target profile infos are scraped at each round

* Remove UserId()
parent 81cd90fd
...@@ -103,14 +103,6 @@ async def Username(_id): ...@@ -103,14 +103,6 @@ async def Username(_id):
return soup.find("a", "fn url alternate-context")["href"].replace("/", "") return soup.find("a", "fn url alternate-context")["href"].replace("/", "")
async def UserId(username):
#loggin.info("[<] " + str(datetime.now()) + ':: get+UserId')
url = f"http://twitter.com/{username}?lang=en"
r = await Request(url)
soup = BeautifulSoup(r, "html.parser")
return int(inf(soup, "id"))
async def Tweet(url, config, conn): async def Tweet(url, config, conn):
#loggin.info("[<] " + str(datetime.now()) + ':: Tweet') #loggin.info("[<] " + str(datetime.now()) + ':: Tweet')
try: try:
...@@ -123,7 +115,7 @@ async def Tweet(url, config, conn): ...@@ -123,7 +115,7 @@ async def Tweet(url, config, conn):
except Exception as e: except Exception as e:
print(str(e) + " [x] get.Tweet") print(str(e) + " [x] get.Tweet")
async def User(url, config, conn): async def User(url, config, conn, user_id = False):
#loggin.info("[<] " + str(datetime.now()) + ':: get+User') #loggin.info("[<] " + str(datetime.now()) + ':: get+User')
try: try:
response = await Request(url) response = await Request(url)
...@@ -132,6 +124,9 @@ async def User(url, config, conn): ...@@ -132,6 +124,9 @@ async def User(url, config, conn):
except Exception as e: except Exception as e:
print(str(e) + " [x] get.User") print(str(e) + " [x] get.User")
if user_id:
return int(inf(soup, "id"))
def Limit(Limit, count): def Limit(Limit, count):
#loggin.info("[<] " + str(datetime.now()) + ':: get+Limit') #loggin.info("[<] " + str(datetime.now()) + ':: get+Limit')
if Limit is not None and count >= int(Limit): if Limit is not None and count >= int(Limit):
......
...@@ -105,7 +105,8 @@ class Twint: ...@@ -105,7 +105,8 @@ class Twint:
self.config.Username = await get.Username(self.config.User_id) self.config.Username = await get.Username(self.config.User_id)
if self.config.Username is not None: if self.config.Username is not None:
self.config.User_id = await get.UserId(self.config.Username) url = f"http://twitter.com/{self.config.Username}?lang=en"
self.config.User_id = await get.User(url, self.config, self.conn, True)
if self.config.TwitterSearch and self.config.Since and self.config.Until: if self.config.TwitterSearch and self.config.Since and self.config.Until:
_days = timedelta(days=int(self.config.Timedelta)) _days = timedelta(days=int(self.config.Timedelta))
...@@ -126,8 +127,6 @@ class Twint: ...@@ -126,8 +127,6 @@ class Twint:
while True: while True:
if len(self.feed) > 0: if len(self.feed) > 0:
if self.config.Followers or self.config.Following: if self.config.Followers or self.config.Following:
url = f"http://twitter.com/{self.config.Username}?lang=en"
await get.User(url, self.config, self.conn)
await self.follow() await self.follow()
elif self.config.Favorites: elif self.config.Favorites:
await self.favorite() await self.favorite()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment