Archived
1
0
Fork 0

Add headers

This commit is contained in:
Dianliang233 2022-01-07 23:01:15 +08:00
parent 63656af42f
commit bf43771a2b
No known key found for this signature in database
GPG key ID: 6C56F399D872F19C
4 changed files with 19 additions and 5 deletions

View file

@ -11,7 +11,11 @@ async def jiki(term: str):
:returns: 查询结果'''
try:
url = 'https://api.jikipedia.com/go/search_entities' + term
text = await post_url(url, data={'page': 1, 'phrase': term, 'size': 1})
text = await post_url(url, data={'page': 1, 'phrase': term, 'size': 1}, headers={'accept': '*/*',
'accept-encoding': 'gzip, deflate',
'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,en-GB;q=0.6',
'content-type': 'application/json',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62'})
print(text)
data = json.loads(text)
count = data['total']

View file

@ -1,10 +1,13 @@
from core.exceptions import AbuseWarning
from modules.wiki import query_pages
from modules.wiki.wikilib_v2 import QueryInfo
async def moegirl(term: str):
result = await query_pages(QueryInfo('https://zh.moegirl.org.cn/api.php'), term)
result = await query_pages(QueryInfo('https://zh.moegirl.org.cn/api.php', headers={'accept': '*/*',
'accept-encoding': 'gzip, deflate',
'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,en-GB;q=0.6',
'content-type': 'application/json',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62'}), term)
msg = ''
if result['msg_list']:
for msg_item in result['msg_list']:

View file

@ -11,7 +11,11 @@ async def nbnhhsh(term: str):
:returns: 查询结果'''
try:
url = 'https://lab.magiconch.com/api/nbnhhsh/guess' + term
text = await post_url(url, data={'text': term})
text = await post_url(url, data={'text': term}, headers={'accept': '*/*',
'accept-encoding': 'gzip, deflate',
'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,en-GB;q=0.6',
'content-type': 'application/json',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62'})
print(text)
data = json.loads(text)['data']
result = data[0]

View file

@ -9,7 +9,10 @@ async def urban(term: str):
:returns: 查询结果'''
try:
url = 'http://api.urbandictionary.com/v0/define?term=' + term
text = await get_url(url)
text = await get_url(url, headers={'accept': '*/*',
'accept-encoding': 'gzip, deflate',
'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,en-GB;q=0.6',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62'})
data = json.loads(text)['list']
if data == []:
return '[Urban Dictionary] 没有找到相关结果。'