mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-17 15:09:31 +00:00
show toefl word
This commit is contained in:
1
Pipfile
1
Pipfile
@@ -13,6 +13,7 @@ python-dotenv = "*"
|
|||||||
gunicorn = "*"
|
gunicorn = "*"
|
||||||
requests = "*"
|
requests = "*"
|
||||||
parsel = "*"
|
parsel = "*"
|
||||||
|
flask-script = "*"
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
coverage = "*"
|
coverage = "*"
|
||||||
|
|||||||
@@ -2,12 +2,15 @@ from flask import Blueprint, render_template, request
|
|||||||
|
|
||||||
bp = Blueprint('main', __name__)
|
bp = Blueprint('main', __name__)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/')
|
@bp.route('/')
|
||||||
|
def word():
|
||||||
|
from rsshub.spiders.word.word import ctx
|
||||||
|
return render_template('main/word.html', **ctx())
|
||||||
|
|
||||||
|
@bp.route('/index')
|
||||||
def index():
|
def index():
|
||||||
return render_template('main/index.html')
|
return render_template('main/index.html')
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/feeds')
|
@bp.route('/feeds')
|
||||||
def feeds():
|
def feeds():
|
||||||
return render_template('main/feeds.html')
|
return render_template('main/feeds.html')
|
||||||
|
|||||||
@@ -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'
|
domain = 'https://www.prnewswire.com'
|
||||||
|
|
||||||
@@ -11,7 +11,9 @@ def parse(post):
|
|||||||
return item
|
return item
|
||||||
|
|
||||||
def ctx(category=''):
|
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')
|
posts = tree.css('.card-list-hr .col-sm-8')
|
||||||
items = list(map(parse, posts))
|
items = list(map(parse, posts))
|
||||||
items = filter_content(items)
|
items = filter_content(items)
|
||||||
|
|||||||
2654
rsshub/spiders/word/toeflwords.txt
Normal file
2654
rsshub/spiders/word/toeflwords.txt
Normal file
File diff suppressed because it is too large
Load Diff
15
rsshub/spiders/word/word.py
Normal file
15
rsshub/spiders/word/word.py
Normal 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}
|
||||||
3
rsshub/templates/main/word.html
Normal file
3
rsshub/templates/main/word.html
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{% block content %}
|
||||||
|
<p>{{ word }}</p>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user