Comments (13)
Just tried it out and it works great. Thanks again! 😀
from unofficial-jisho-api.
Hi, thanks for the issue. I'll see about adding an argument so that you can specify request parameters such as proxy.
In the meantime, looking at request's documentation it sounds like you can set an HTTP_PROXY environment variable and it should use that. Not the greatest solution but should work in a pinch.
from unofficial-jisho-api.
Ah ok cool, thanks!
from unofficial-jisho-api.
I added a way to configure request options in the newly available version 1.1.2.
Check out the updated README for examples of how to configure a proxy.
Feel free to reopen the issue if there's any problem :)
from unofficial-jisho-api.
That was so fast -- thank you!
I'm trying it out now and getting an error (see image).
This is the configuration I used:
const jishoApi = require('unofficial-jisho-api');
const jisho = new jishoApi({ proxy: 'https://cors-anywhere.herokuapp.com/' });
jisho.searchForPhrase('日').then(result => {
console.log(result);
});
If I use that proxy and make a fetch request directly to the Jisho API it works fine with something like this:
const proxy = 'https://cors-anywhere.herokuapp.com/'
const word = '余計';
const url = proxy + 'http://jisho.org/api/v1/search/words?keyword=' + word;
const response = await fetch(url);
const json = await response.json();
console.log(json)
from unofficial-jisho-api.
Ah that proxy is a little bit weird, I don't think you can make it work by specifying options to the request module. How about this then, I'll expose the parsing functions and then you can get the HTML body of the page however works for you, pass it into the parsing functions, and get JSON out.
from unofficial-jisho-api.
So for phrase search (official API) you would do
const proxy = 'https://cors-anywhere.herokuapp.com/'
const word = '余計';
const url = proxy + jisho.getUriForPhraseSearch(word);
const response = await fetch(url);
const json = await response.json();
console.log(json);
And for kanji search:
const proxy = 'https://cors-anywhere.herokuapp.com/'
const kanji = '余';
const url = proxy + jisho.getUriForKanjiSearch(kanji);
const response = await fetch(url);
const json = jisho.parseKanjiPageHtml(await response.body()); // Or however you access the body of the response using whatever library you're using for HTTP requests
console.log(json);
Would that work?
from unofficial-jisho-api.
Yeah for sure! That works for me. And one of the main things I'd want to get would be the sentences.
Let me know if I can help with any of this too! I appreciate everything you've already put together. Also, there's a chance I'll end up creating my own database with the dictionary/sentence files eventually so I don't want to feel like I've requested stuff from you that I didn't use enough.
from unofficial-jisho-api.
Please try out the new v1.1.3 and let me know if it gets the job done :) Examples for fetching the pages yourself and having the module parse them are near the bottom of the updated README
For the sentences, the furigana has mistakes 5-10% of the time. At some point I'd like to see about improving that. If you notice sentences where the API returns different furigana compared to the Jisho.org website, feel free to comment on the issue I have open for that and include the search term and the incorrect sentence.
By the way, if you don't need the furigana, you might consider downloading Tatoeba, that's where (all of?) Jisho's example sentences come from and you can download their entire database as a big TSV file.
from unofficial-jisho-api.
Hey sorry for the late response -- had a busy week! I'm about to run back out but should be able to try out the new features within the next couple of days. Thanks again for adding this stuff! :)
And I appreciate the link to Tatoeba! I've been thinking about just downloading the files like you said and setting up my own server.
from unofficial-jisho-api.
hi @mistval ohayo gozaimasu, is there really no other way than to make a proxy server to resolve the CORS issue? thank you in advance
from unofficial-jisho-api.
Hi @gfreecs0510 If you want to use this package (or the Jisho API in general) in a website, you'll have to use a proxy (or maybe try asking nicely on Jisho's forum for them to allow CORS).
from unofficial-jisho-api.
@mistval thank you very much, cheers :)
from unofficial-jisho-api.
Related Issues (15)
- Pagination HOT 2
- Undefined <result.strokeOrderSvgUri> HOT 4
- Searching for Kanji with more than one is not found HOT 1
- TS bindings for phrase scrape have incorrect type for meanings property HOT 1
- reading of jukugo HOT 6
- Make searchForPhrase independent of Jisho API HOT 2
- Errors in parsing furigana
- sameSite attribute issue HOT 2
- Example sentence for word scrape senses occasionally misses pieces
- Stroke order animation HOT 4
- Enable Option for CORS HOT 1
- Attempting to import this project into my React Native Project HOT 4
- Word Type Search HOT 5
- Associate furigana with phrases in searchForExamples HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unofficial-jisho-api.