HTTPError: HTTP Error 403: Forbidden. wget with python - python

I am using Python with Jupyter Notebook.
This program downloads many pdfs and works on other machines, however when putting it on another machine with Windows Server 2016 Standard it shows an error.
The function that is causing the error is:
def download_doc(pasta_pdf,base_links):
os.chdir(pasta_pdf)
for link in base_links['Link_Download_Regulamento']:
if link != None:
wget.download(link)
else:
continue
download_doc(pasta_origem,df_regulamentos_novos)
The error print:
enter image description here
Thanks for your assistance.

You got
HTTPError: HTTP Error 403: Forbidden
If you got information about HTTP response status code, but do not know what it does mean, then you might consult developer.mozilla.org docs, in this case this is 403 Forbidden
The client does not have access rights to the content; that is, it is
unauthorized, so the server is refusing to give the requested
resource. Unlike 401, the client's identity is known to the server.

Related

Error loading vectors in fasttext/torchtext

I get the following error:
urllib.error.HTTPError: HTTP Error 403: Forbidden
When running this:
class FastText(Vectors):
url_base = 'https://s3-us-west-1.amazonaws.com/fasttext-vectors/wiki.{}.vec'
def __init__(self, language="en", **kwargs):
url = self.url_base.format(language)
name = os.path.basename(url)
super(FastText, self).__init__(name, url=url, **kwargs)
How can I fix it?
Changing the url and that did not work
An HTTP 403 "Forbidden" error means that the server to which you've sent your request is refusing to let you access that URL, perhaps because it's not open to the public, or requires extra authentication.
If I try the URL https://s3-us-west-1.amazonaws.com/fasttext-vectors/wiki.en.vec from a web-browser, I get the same error. So this isn't really an issue with your code, or python, or pytorch, or fasttext. You've just got an improper expectation that the given URL will return what you wnat it to.
What reference, or entity, made you think https://s3-us-west-1.amazonaws.com/fasttext-vectors/wiki.en.vec would give you what you need? You may need to follow-up with whoever recommended that URL, and let them know their recommendation does not work, or find an alternate source.
Only if an URL works for you in your browser should you expect it will also work in your code, with no extra authentication steps. And, it still might break for other reasons, like the system where your code is running having a disfavored network IP-address – so before supplying such an URL to configure a custom subclass of Vectors, you might run some code from that same system to verify the URL loads at all.

How to fix a 403 forbidden error when sending a text using Twilio and waiting for response from server?

I am using webhooks to try and get a response from my texts using Twilio. However, I am getting a 403 forbidden error when I send a message to the server, and of course not getting a response as a result. My firewall is turned off on my Mac so I know it's not that blocking it.
Here are some more details from ngrok:
Content-type: application/x-www-form-urlencoded
I-Twilio-Idempotency-Token: f44545da-e917-46e6-b24b-e9bf6f727a49
X-Forwarded-For: 3.93.218.220
X-Twilio-Signature: F5mURKfEP6sM/DMGiOFcYPD7lKo=
Host: 843e-167-98-155-255.eu.ngrok.io
User-Agent: TwilioProxy/1.1
Acceptance encoding: gzip
X-forwarded protocol: https
Let me know if any other details are required- I couldn't get logs from ngrok.
I found a similar post, but I checked and my firewall is NOT turned on: How to fix 403 error what Twilio calls my webhook?

Python - JIRAerror hhtp 403 url captcha challenge

Hi I am trying to connect to Jira python package JIRA
Here is command
j_url = 'https://myserver.com/jira'
JIRA(j_url, auth=(user, pass), max_retries=5)
I am getting the following error. I was not getting this error before. Only thing is changed, I did changed my password yesterday and it failed few times
JIRAError: JiraError HTTP 403 url: https://xxxxxxx/jira/rest/auth/1/session
text: CAPTCHA_CHALLENGE; login-url=xxxxxx/jira/login.jsp
Any idea what could be possible issue here?
It is solved now.
There is Current failed logins count in Jira profile. If it exceed certain threshold then API is failing. You need to get it reset by Admin

500 internal error only when running from windows (7)

Problem: the program is facing a 500 Internal Error when accessing a website using this code: (I work with PyQt)
Happens only on my windows box (WIN7) and not on my linux (ubuntu 12.04 LTS) fyi they are different computers (but on the same LAN)
def sendBearer_req(self):
request = QNetworkRequest()
request.setUrl(QUrl("https://api.twitter.com/oauth2/token"))
request.setRawHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8')
request.setRawHeader('Authorization', 'Basic %s' % cons_enc)
self.network_manager = QNetworkAccessManager()
if self.network_manager.receivers(SIGNAL("finished")) > 0:
self.network_manager.finished.disconnect()
self.network_manager.finished.connect(self._request_finished)
self.network_manager.post(request, self.urlencode_post({'grant_type' : 'client_credentials'}))
def _request_finished(self, reply):
if not reply.error() == QNetworkReply.NoError:
# request probably failed
print(reply.error())
print(reply.errorString())
print("retrying")
self.sendBearer_req()
else:
self.sendBearer(reply)
Output:
299
Error downloading URL - server replied: Internal Server Error
retrying
where URL is the page url.
I tried it with many URLs in case the problem was really in the server itself but it's not.
cons_enc is valid (b64 encoded string)
How to fix it? and if you know why in ubuntu it works?
Status code 299 is non-standard and the Twitter API Error Code Reference does not list it. Likely the cause is not related to this stub of code
QNetworkReply defines code 299 as "unknown error", maybe it's a Qt bug.
As a suggestion, try using a proper Twitter API for Python.
Problem found, apparently I runned it accidently on Python 3.3 on windows and it was built for Python 2.7 (which was used in the linux box).
Maybe PyQt should check that before starting up!

How to get the content of "Google Dictionary" by python script

Thank to the script, I've logged in google successfully.
But I replaced the value of "gv_home_page_url" with http:// www.google.com.tw/dictionary/wordlist?hl=zh-TW, the error occured.
The message is "
urllib2.HTTPError: HTTP Error 500: Internal Server Error"
Any idea will be appreciated, thanks.
That's not a valid URL. If you try to enter it in your bar, you'll get redirected to Google search results. Using urllib2, you'll get an error.
See here for another way to get data from Google Dictionary:
http://googlesystem.blogspot.com/2009/12/on-googles-unofficial-dictionary-api.html
Does Google require an SSL url? You're using "http://" but the example script uses "https://"

Categories