urllib.request.urlretrieve not working over HTTP websites, however the same is able to save url over HTTPS websites.
import urllib.request
abc="http://www.google.com"
urllib.request.urlretrieve(abc,"C:\\Users\\kj\\downloads\\abc.html")
I'm getting the following error:
[WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond>
When i use "https://www.google.com", the code is working. I am currently working on a website which is not a secured website (http), and this code is not working on them.
I have read few threads on this portal, but could not find a solution.
i am using python 3.6.
Any suggestions?
Related
I am helping my client to solve a problem. He tries to call my API but is unsuccessful.
Situation:
my API is accessible via postman and the browser (swagger). It works.
On the same computer via a python script I cannot access to the API
error:
Caused by NewCOnnectionError('<urllib3.connection.HTTPConnection object at 0x000001310A6F5C0>:
Failed to establish a new connection: [Errno 11001] getaddrinfo failed')
If I try a very simple script
import requests
r = requests.get('http://google.com')
I get the same error.
I assume there some problem with firewall/proxy but why does Postman work?
In which direction can I direct my client to solve problem?
I also tried ping and it doesn't work either:
$ ping www.google.com
Ping request could not found host www.google.com. Pleas check the name and try again.
I try to make a script logging on to a website, and I think my code is correct, but gets the following error code: "Could not connect because the destination computer actively denied it"
Is it possible to make a website that can refuse access for Selenium?
I have inserted the entire error code here, sorry that the last part is in Danish:
Shell Error message
It is TCP error code 10061: No connection could be made because the target machine actively refused it.
It's possible that the website has no services listening on the specified port, or there is a firewall stopping you.
My code is as follows:
I always get this error when I try to send a email. Could you help me.
error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I recommend reading the example in the manual located at https://docs.python.org/3/library/smtplib.html
You would need to make sure your firewall operating system and LAN router allows outgoing traffic on port 25.
Also, set verbose debug level as per manual server.set_debuglevel(1)
Try sending out test emails via localhost using terminal commands, to make sure the os can definitely send out emails, and that it isn't a python code issue.
I'm getting the following error when trying to fetch an URL with urllib2 in the google app engine:
error: An error occured while connecting to the server: Unable to fetch URL: http://www.google.com Error: [Errno 10106] getaddrinfo failed
This is the code calling the urllib2 open read methods:
def get(self):
self.write(urllib2.urlopen("http://www.google.com").read())
self.render_index()
Nothing fancy, just a call to the library inside the main handler to ouptut the fetched text.
My PC resolves DNS correctly. I can use the urllib2 library from the python interpeter, fetching URLs successfully.
The deployed code running from the google servers work as intended, it's something with my local environment but I can't find what is it.
I also tried using urlfetch from gae with similar results (same getaddrinfo failed)
I switched to Google DNS some days before working with the urllib2 library but switching back to ISP provided DNS didn't work either.
EDIT: When calling the function with an IP address the URL is fetched:
self.write(urllib2.urlopen("http://173.194.42.34").read())
Thanks in advance!
I'm fairly certain that your DNS resolver fails to resolve the hostname. I assume that your OS, or security software prohibits the devserver from creating outbound connection. Another possibility would be that you have invalid entry in your hosts file on your operating system.
Also, there are many similar questions which could help you.
I'm getting the following error when trying to fetch an URL with urllib2 in the google app engine:
error: An error occured while connecting to the server: Unable to fetch URL: http://www.google.com Error: [Errno 10106] getaddrinfo failed
This is the code calling the urllib2 open read methods:
def get(self):
self.write(urllib2.urlopen("http://www.google.com").read())
self.render_index()
Nothing fancy, just a call to the library inside the main handler to ouptut the fetched text.
My PC resolves DNS correctly. I can use the urllib2 library from the python interpeter, fetching URLs successfully.
The deployed code running from the google servers work as intended, it's something with my local environment but I can't find what is it.
I also tried using urlfetch from gae with similar results (same getaddrinfo failed)
I switched to Google DNS some days before working with the urllib2 library but switching back to ISP provided DNS didn't work either.
EDIT: When calling the function with an IP address the URL is fetched:
self.write(urllib2.urlopen("http://173.194.42.34").read())
Thanks in advance!
I'm fairly certain that your DNS resolver fails to resolve the hostname. I assume that your OS, or security software prohibits the devserver from creating outbound connection. Another possibility would be that you have invalid entry in your hosts file on your operating system.
Also, there are many similar questions which could help you.