urllib error URLError urlopen error Errno -2 Name or service not known

0 votes

Hi Guys,

I am trying to browse one URL using the urllib module. But it is showing me the below error.

html = urlopen("http://en.wikipedia.org" + articleUrl)
urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>

How can I solve this error?

Jul 15, 2020 in Python by akhtar
• 38,230 points
2,971 views

1 answer to this question.

0 votes

Hi@akhtar,

You need to use the read function in your command to get the response content. You can use the below command to avoid this error.

html = urlopen("http://en.wikipedia.org" + articleUrl).read()
answered Jul 15, 2020 by MD
• 95,360 points

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

Python argparse error "NameError: name 'file' is not defined"

The right datatype for destination in argpasrse module ...READ MORE

answered Nov 28, 2018 in Python by Omkar
• 69,210 points
10,382 views
0 votes
3 answers

Python error "NameError: name 'sr' is not defined"

NameError: name 'xx' is not defined Python knows ...READ MORE

answered Mar 19, 2020 in Python by rahul
• 360 points
37,768 views
0 votes
1 answer

How to print a message or the error if a file is not found?

To print the message that file is not ...READ MORE

answered Jan 2, 2019 in Python by Omkar
• 69,210 points
614 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,903 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
2,135 views
0 votes
1 answer

Error executing Jupyter command 'notebook': [Errno 2] No such file or directory

Hi@akhtar, I think there is a problem with ...READ MORE

answered Jun 25, 2020 in Python by MD
• 95,360 points
3,111 views
0 votes
1 answer

How to solve the urllib.error.URLError

Hi@Jefferson, You need to use the read function in your ...READ MORE

answered Jul 15, 2020 in Python by MD
• 95,360 points
1,279 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP