SavchenkoValeriy / emacs-powerthesaurus

Powerthesaurus integration for Emacs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error connecting to powerthesaurus

ntrocado opened this issue · comments

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?

Thank you for reporting.

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

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.

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

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.

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

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...

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)))))))

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

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.

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