From 9f64e1eaca88774ae6bf5a48bed4dc0f97bf2982 Mon Sep 17 00:00:00 2001 From: Hell13Cat <46496367+Hell13Cat@users.noreply.github.com> Date: Tue, 28 Dec 2021 23:38:27 +0300 Subject: [PATCH] build0001 --- .gitignore | 2 ++ db.py | 15 +++++++++++++++ main.py | 26 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 db.py create mode 100644 main.py diff --git a/.gitignore b/.gitignore index b6e4761..1d043b3 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,8 @@ share/python-wheels/ .installed.cfg *.egg MANIFEST +test.py +tmp.txt # PyInstaller # Usually these files are written by a python script from a template diff --git a/db.py b/db.py new file mode 100644 index 0000000..11565a7 --- /dev/null +++ b/db.py @@ -0,0 +1,15 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +import pickle, os + +def load(name): + file = open(os.getcwd() + "/db/" + name + ".pk", "rb") + res = pickle.load(file) + file.close() + return res + +def save(name, setting): + file = open(os.getcwd() + "/db/" + name + ".pk", "wb") + pickle.dump(setting, file) + file.close() \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..e11627d --- /dev/null +++ b/main.py @@ -0,0 +1,26 @@ +import db +import requests +from bs4 import BeautifulSoup +import wget +import os +import cfscrape + +def whatisthis(s): + if isinstance(s, str): + print("ordinary string") + elif isinstance(s, unicode): + print("unicode string") + else: + print("not a string") + print(type(s)) + +def get_data(url): + datas = {} + scraper = cfscrape.CloudflareScraper() + req = scraper.get(url) + soup = BeautifulSoup(req.text, 'lxml') + datas["url"] = url + datas["title"] = soup.find("title").text + datas["text"] = (soup.find("body").text).replace("\\n", " ") + whatisthis(datas["text"]) + return datas \ No newline at end of file