mirror of
https://0xacab.org/johnxina/rat.git
synced 2024-12-23 13:09:08 +00:00
fix hinting rate limit when scaping: add an option to use native api only
This commit is contained in:
parent
d3972baf1e
commit
e4cfcd84ed
12
app.py
12
app.py
@ -136,8 +136,16 @@ async def forum_view():
|
|||||||
sort = int(request.args.get('sort') or 0)
|
sort = int(request.args.get('sort') or 0)
|
||||||
|
|
||||||
async with aiotieba.Client() as tieba:
|
async with aiotieba.Client() as tieba:
|
||||||
forum_info, threads = await asyncio.gather(awaitify(find_tieba_info)(fname),
|
if only_use_native_api:
|
||||||
tieba.get_threads(fname, pn=pn, sort=sort))
|
forum_info, threads = await asyncio.gather(tieba.get_forum_detail(fname),
|
||||||
|
tieba.get_threads(fname, pn=pn, sort=sort))
|
||||||
|
forum_info = { 'avatar': 'a6efce1b9d16fdfa6291460ab98f8c5495ee7b51.jpg',
|
||||||
|
'topic': forum_info.post_num, 'thread': forum_info.post_num,
|
||||||
|
'member': forum_info.member_num, 'desc': '贴吧描述暂不可用', 'name': forum_info.fname }
|
||||||
|
else:
|
||||||
|
forum_info, threads = await asyncio.gather(awaitify(find_tieba_info)(fname),
|
||||||
|
tieba.get_threads(fname, pn=pn, sort=sort))
|
||||||
|
|
||||||
if threads.page.current_page > threads.page.total_page or pn < 1:
|
if threads.page.current_page > threads.page.total_page or pn < 1:
|
||||||
return await render_template('error.html', msg = \
|
return await render_template('error.html', msg = \
|
||||||
f'请求越界,本贴吧共有 { threads.page.total_page } 页'
|
f'请求越界,本贴吧共有 { threads.page.total_page } 页'
|
||||||
|
@ -17,6 +17,7 @@ app = Flask(__name__)
|
|||||||
app.config['SERVER_NAME'] = '127.0.0.1:8886'
|
app.config['SERVER_NAME'] = '127.0.0.1:8886'
|
||||||
|
|
||||||
should_fetch_comments = True
|
should_fetch_comments = True
|
||||||
|
only_use_native_api = True
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user