Re: I'm getting a NewConnectionError while using reqeusts.

589 views
Skip to first unread message

Antonio Alvarez Ramirez

unread,
Dec 22, 2019, 7:40:50 AM12/22/19
to django...@googlegroups.com
Hello ,

You add four wwww !!! ;-) try yo remove one 

Bye , and have nice day 

El dom., 22 dic. 2019 8:55, Aaryan Dewan <dewan...@gmail.com> escribió:
I was making a simple django application in which it will lookup to google.com and display all the links. Here's some of the code( that's causing the error ):

from django.shortcuts import render, HttpResponse
import requests
from bs4 import BeautifulSoup

def scrape(request):

    page = requests.get('https://wwww.google.com')
    soup = BeautifulSoup(page.text, 'html.parser')
    ...

When I try to run the local Django server and open localhost:8000 I get this error:

ConnectionError at / 

HTTPSConnectionPool(host='wwww.google.com',
port=443): Max retries exceeded with url: / (Caused by
NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object
at 0x056BFB50>: Failed to establish a new connection: [Errno 11001]
getaddrinfo failed'))

On the other hand, if I try running `page = requests.get("https://www.google.com")` on a python shell in the command prompt, it works fine with no errors. 

I tried to use `time.sleep` as it was mentioned in some SE answer but that did not help. So how should I go about fixing this?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7353725f-ae5c-4756-9cf3-67e1e1dfc449%40googlegroups.com.

Karan Mittal

unread,
Dec 22, 2019, 8:44:00 AM12/22/19
to django...@googlegroups.com
Hey Aryan, Hope this helps.
sublime_text_RnE1W8IKhx.png
Regards, 
Karan Mittal


Karan Mittal

unread,
Dec 22, 2019, 8:45:17 AM12/22/19
to django...@googlegroups.com
Do check out the project. I have it on this github link.
Its a news scrapper using requests and bs4.

Aaryan Dewan

unread,
Dec 22, 2019, 9:24:58 AM12/22/19
to Django users
OMG! Its hard to believe that a single 'w' can jeopardize your entire program! Thanks :)


On Sunday, December 22, 2019 at 6:10:50 PM UTC+5:30, Antonio Alvarez Ramirez wrote:
Hello ,

You add four wwww !!! ;-) try yo remove one 

Bye , and have nice day 

El dom., 22 dic. 2019 8:55, Aaryan Dewan <dewan...@gmail.com> escribió:
I was making a simple django application in which it will lookup to google.com and display all the links. Here's some of the code( that's causing the error ):

from django.shortcuts import render, HttpResponse
import requests
from bs4 import BeautifulSoup

def scrape(request):

    page = requests.get('https://wwww.google.com')
    soup = BeautifulSoup(page.text, 'html.parser')
    ...

When I try to run the local Django server and open localhost:8000 I get this error:

ConnectionError at / 

HTTPSConnectionPool(host='wwww.google.com',
port=443): Max retries exceeded with url: / (Caused by
NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object
at 0x056BFB50>: Failed to establish a new connection: [Errno 11001]
getaddrinfo failed'))

On the other hand, if I try running `page = requests.get("https://www.google.com")` on a python shell in the command prompt, it works fine with no errors. 

I tried to use `time.sleep` as it was mentioned in some SE answer but that did not help. So how should I go about fixing this?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

Aaryan Dewan

unread,
Dec 22, 2019, 9:25:17 AM12/22/19
to Django users
Thanks Karan
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages