show toefl word

This commit is contained in:
hillerliao
2020-06-24 15:35:24 +08:00
parent bf14280a80
commit 34157d7f0e
6 changed files with 2682 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ python-dotenv = "*"
gunicorn = "*"
requests = "*"
parsel = "*"
flask-script = "*"
[dev-packages]
coverage = "*"

View File

@@ -2,12 +2,15 @@ from flask import Blueprint, render_template, request
bp = Blueprint('main', __name__)
@bp.route('/')
def word():
from rsshub.spiders.word.word import ctx
return render_template('main/word.html', **ctx())
@bp.route('/index')
def index():
return render_template('main/index.html')
@bp.route('/feeds')
def feeds():
return render_template('main/feeds.html')

View File

@@ -1,4 +1,4 @@
from rsshub.utils import fetch, filter_content
from rsshub.utils import fetch, filter_content, DEFAULT_HEADERS
domain = 'https://www.prnewswire.com'
@@ -11,7 +11,9 @@ def parse(post):
return item
def ctx(category=''):
tree = fetch(f"{domain}/news-releases/financial-services-latest-news/earnings-list/?page=1&pagesize=100")
# DEFAULT_HEADERS.update({'upgrade-insecure-requests': 1})
url = f"{domain}/news-releases/financial-services-latest-news/earnings-list/?page=1&pagesize=100"
tree = fetch(url, headers=DEFAULT_HEADERS)
posts = tree.css('.card-list-hr .col-sm-8')
items = list(map(parse, posts))
items = filter_content(items)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
import random
import linecache
import sys
from os import path
file_path = path.dirname(path.realpath(__file__))
def ctx():
file = path.join(file_path,'toeflwords.txt')
with open(file, encoding='utf-8') as inf:
f = inf.readlines()
count = len(f)
wordnum = random.randrange(0, count, 1)
word = linecache.getline(file, wordnum)
return {"word": word}

View File

@@ -0,0 +1,3 @@
{% block content %}
<p>{{ word }}</p>
{% endblock %}