SavchenkoValeriy / emacs-powerthesaurus

Powerthesaurus integration for Emacs
GNU General Public License v3.0
269 stars 11 forks source link

Error connecting to powerthesaurus #6

Closed ntrocado closed 5 years ago

ntrocado commented 5 years ago

I'm getting this:

REQUEST [error] Error (error) while connecting to https://www.powerthesaurus.org/find/synonyms.

(when searching for "find") I can open the link in a browser just fine. I'm on Win10. Emacs version is GNU Emacs 26.1 (build 1, x86_64-w64-mingw32) of 2018-05-30.

Any ideas?

SavchenkoValeriy commented 5 years ago

Thank you for reporting.

That might be a limitation of request.el that I use. I've never tried it on Windows

tgkolda commented 5 years ago

I'm having the same problem. I am behind a firewall, but I have set the url-proxy-services variable so that services like MEPLA do work.

matthew-piziak commented 5 years ago

https://www.powerthesaurus.org/ returns 403 Forbidden for me.

bard commented 5 years ago

Could it be that powerthesaurus.org blacklists IPs based on attempted usage? The site was working for me before trying to use it from Emacs. https://twitter.com/ndw/status/1097858254204489728 suggests that 403 is indeed IP based.

matthew-piziak commented 5 years ago

I have switched to synosaurus, which is operational as well as being more actively maintained.

galaunay commented 5 years ago

Just as an update.

trying to use curl on powerthesaurus.org give back:

Request has been forbidden by the server.

If you believe you are getting this message by mistake, please email us with your IP address (xxx.xxx.xxx.xxx).

- The Power Thesaurus Team

So I guess they just don't want requests...

DavidFoleyOfferLogic commented 5 years ago

I had the same issue and redefined powerthesaurus-lookup-word to include user-agent header set to the firefox agent as part of the request and it appears to be working.

(defun powerthesaurus-lookup-word (&optional beginning end)
    "Find the given word's synonyms at powerthesaurus.org.
`BEGINNING' and `END' correspond to the selected text with a word to replace.
If there is no selection provided, additional input will be required.
In this case, a selected synonym will be inserted at the point."
    (interactive
     ;; it is a simple interactive function instead of interactive "r"
     ;; because it doesn't produce an error in a buffer without a mark
     (if (use-region-p) (list (region-beginning) (region-end))
       (list nil nil)))
    (let* ((word (powerthesaurus-get-original-word beginning end))
           (callback (powerthesaurus-choose-callback beginning end)))
      (request
       (powerthesaurus-compose-url word)
       :parser (lambda () (libxml-parse-html-region (point) (point-max)))
       :headers '(("User-Agent" . "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0"))
       :success (cl-function (lambda (&key data &allow-other-keys)
                               ;; in order to allow users to quit powerthesaurus
                               ;; prompt with C-g, we need to wrap callback with this
                               (with-local-quit
                                 (powerthesaurus-pick-synonym data)))))))
ntrocado commented 5 years ago

Unfortunately this didn't work for me... Can anyone else test?

galaunay commented 5 years ago

Work for me, thanks ! EDIT: Still doesn't work for time to time. Apparently when making too many requests on a short amount of time.

SavchenkoValeriy commented 5 years ago

I've based my solution on the comment by @breaker331. Tried to reproduce the behaviour described by @galaunay, but no success unfortunately (or luckily).

Fix is in 81d6a03