mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 16:48:58 +00:00
Compare commits
No commits in common. "a9fcda794c8e1e5bb584d7b7d9c721cc6079aee2" and "ea8e46c07ce9adcf315c4cde4081f3ec01a16a7d" have entirely different histories.
a9fcda794c
...
ea8e46c07c
2 changed files with 4 additions and 14 deletions
14
scrape.py
14
scrape.py
|
@ -9,14 +9,6 @@ import functions
|
|||
cfg = json.load(open('config.json'))
|
||||
|
||||
def scrape_posts(account):
|
||||
db = MySQLdb.connect(
|
||||
host = cfg['db_host'],
|
||||
user=cfg['db_user'],
|
||||
passwd=cfg['db_pass'],
|
||||
db=cfg['db_name'],
|
||||
use_unicode=True,
|
||||
charset="utf8mb4"
|
||||
)
|
||||
handle = account[0]
|
||||
outbox = account[1]
|
||||
print("Scraping {}".format(handle))
|
||||
|
@ -86,14 +78,12 @@ def scrape_posts(account):
|
|||
|
||||
if r.status_code == 429:
|
||||
# we are now being ratelimited, move on to the next user
|
||||
print("Hit rate limit while scraping {}".format(handle))
|
||||
done = True
|
||||
else:
|
||||
j = r.json()
|
||||
|
||||
db.commit()
|
||||
|
||||
db.commit()
|
||||
print("Finished scraping {}".format(handle))
|
||||
|
||||
print("Establishing DB connection")
|
||||
|
@ -111,9 +101,9 @@ cursor = db.cursor()
|
|||
print("Downloading posts")
|
||||
cursor.execute("SELECT `handle`, `outbox` FROM `fedi_accounts` ORDER BY RAND()")
|
||||
accounts = cursor.fetchall()
|
||||
cursor.close()
|
||||
db.close()
|
||||
with Pool(cfg['service_threads']) as p:
|
||||
p.map(scrape_posts, accounts)
|
||||
|
||||
db.commit()
|
||||
|
||||
print("Done!")
|
||||
|
|
4
webui.py
4
webui.py
|
@ -287,7 +287,7 @@ def bot_accounts_add():
|
|||
|
||||
if r.status_code == 200:
|
||||
j = r.json()
|
||||
if 'contact_account' in j and 'is_pro' in j['contact_account']:
|
||||
if 'is_pro' in j['contact_account']:
|
||||
# gab instance
|
||||
error = "Gab instances are not supported."
|
||||
return render_template("bot_accounts_add.html", error = error)
|
||||
|
@ -395,7 +395,7 @@ def bot_create():
|
|||
session['instance_type'] = "Pleroma"
|
||||
session['step'] += 1
|
||||
else:
|
||||
if 'contact_account' in j and 'is_pro' in j['contact_account']:
|
||||
if 'is_pro' in j['contact_account']:
|
||||
# gab instance
|
||||
session['error'] = "Gab instances are not supported."
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue