mirror of
https://github.com/anatolykopyl/vk-bingo.git
synced 2026-03-26 12:54:25 +00:00
🗃️ Генератор базы данных готов!
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,6 +7,7 @@ node_modules
|
|||||||
# local env files
|
# local env files
|
||||||
.env.local
|
.env.local
|
||||||
.env.*.local
|
.env.*.local
|
||||||
|
.env
|
||||||
|
|
||||||
# Log files
|
# Log files
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
import os
|
import os
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import pymongo
|
from pymongo import MongoClient
|
||||||
|
from decouple import config
|
||||||
|
|
||||||
DIRECTORY = "messages/"
|
DIRECTORY = "messages/"
|
||||||
|
HOST_NAME = config('HOST_NAME')
|
||||||
|
HOST_URL = config('HOST_URL')
|
||||||
|
|
||||||
|
client = MongoClient(host="localhost", port=27017)
|
||||||
|
db = client.vk_bingo
|
||||||
|
|
||||||
for filename in os.listdir(DIRECTORY):
|
for filename in os.listdir(DIRECTORY):
|
||||||
if filename.endswith(".html"):
|
if filename.endswith(".html"):
|
||||||
@@ -12,6 +18,16 @@ for filename in os.listdir(DIRECTORY):
|
|||||||
if (str(attch_desc.string) == "Фотография"):
|
if (str(attch_desc.string) == "Фотография"):
|
||||||
image = str(attch_desc.find_next_sibling().string)
|
image = str(attch_desc.find_next_sibling().string)
|
||||||
head = attch_desc.find_next_sibling().parent.parent.parent.find_previous_sibling()
|
head = attch_desc.find_next_sibling().parent.parent.parent.find_previous_sibling()
|
||||||
name = str(head.a and head.a.string or "Толя Копыл")
|
name = str(head.a and head.a.string or HOST_NAME)
|
||||||
date = str(head.text).split(", ")[1].replace(" (ред.)", "")
|
date = str(head.text).split(", ")[1].replace(" (ред.)", "")
|
||||||
|
link = str(head.a and head.a['href'] or HOST_URL)
|
||||||
|
|
||||||
|
card = {
|
||||||
|
"image": image,
|
||||||
|
"name": name,
|
||||||
|
"link": link,
|
||||||
|
"date": date
|
||||||
|
}
|
||||||
|
|
||||||
|
db.cards.insert_one(card)
|
||||||
|
|
||||||
|
|||||||
3
archive/requirements.txt
Normal file
3
archive/requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
bs4
|
||||||
|
pymongo
|
||||||
|
python-decouple
|
||||||
Reference in New Issue
Block a user