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,170 points
1,513 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,200 points

Related Questions In Python

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,150 points
8,070 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
33,871 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,150 points
279 views
0 votes
1 answer

What to do when I get and error saying python not recognized as internal or external command?

You need to set up the path ...READ MORE

answered May 28, 2019 in Python by Fata
• 1,050 points
673 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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,161 views
0 votes
0 answers
+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,810 points
1,629 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,200 points
1,501 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,200 points
596 views