Commit 06bf75da authored by Cody Zacharias's avatar Cody Zacharias Committed by GitHub

Update followers.py

parent 086a6bb1
from . import feed, get, db, output, elasticsearch from . import feed, get, db, output, elasticsearch
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import aiohttp
import asyncio import asyncio
import re import re
import sys import sys
...@@ -12,8 +11,11 @@ class Followers: ...@@ -12,8 +11,11 @@ class Followers:
self.count = 0 self.count = 0
self.config = config self.config = config
if self.config.Elasticsearch:
print("[+] Indexing to Elasticsearch @ " + str(self.config.Elasticsearch))
if self.config.Database: if self.config.Database:
print("Inserting into Database: " + str(self.config.Database)) print("[+] Inserting into Database: " + str(self.config.Database))
self.conn = db.init(self.config.Database) self.conn = db.init(self.config.Database)
if isinstance(self.conn, str): if isinstance(self.conn, str):
print(str) print(str)
...@@ -23,16 +25,14 @@ class Followers: ...@@ -23,16 +25,14 @@ class Followers:
loop.run_until_complete(self.main()) loop.run_until_complete(self.main())
async def Feed(self): async def Feed(self):
ua = {'User-Agent': 'Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/0.8.12'} url = await get.Url(self.config, self.init).followers()
connect = aiohttp.TCPConnector(verify_ssl=False) response = await get.MobileRequest(self.config, url)
async with aiohttp.ClientSession(headers=ua, connector=connect) as session:
response = await get.Response(session, await get.Url(self.config,
self.init).followers())
self.feed = [] self.feed = []
try: try:
self.feed, self.init = feed.Follow(response) self.feed, self.init = feed.Follow(response)
except: except:
pass pass
return self.feed return self.feed
async def follower(self): async def follower(self):
...@@ -46,14 +46,16 @@ class Followers: ...@@ -46,14 +46,16 @@ class Followers:
output.write(User.name, self.config.Output) output.write(User.name, self.config.Output)
if self.config.Elasticsearch: if self.config.Elasticsearch:
elasticsearch.Follow(self.config.Elasticsearch, User.name, self.config.Username, self.config.Essid) elasticsearch.Follow(self.config.Elasticsearch, User.name,
self.config.Username, self.config.Essid)
self.count += 1 self.count += 1
print(User.name) print(User.name)
async def main(self): async def main(self):
if self.config.User_id is not None: if self.config.User_id is not None:
self.config.Username = await get.Username(self.config.User_id) self.config.Username = await get.Username(self.config)
while True: while True:
if len(self.feed) > 0: if len(self.feed) > 0:
await self.follower() await self.follower()
......
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