0

I have a problem with reading data from websites. Currently, while working on a desktop computer, I used the Pandas library. In its simplest form, the code looks like this:

df = pd.read_html('https://en.wikipedia.org/wiki/Coal', header = 0, decimal=",", thousands='.')
df[3].head()

and thanks to it I was able to download data without any problems. The problem occurred when I wanted to download data on my computer at work in the same way. One of the pages worked correctly and the code given above correctly downloaded the data, but on practically all the other pages when I run the code I get the following message.

URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it

Does anyone know how to deal with it? Why for one website the code worked correctly and for the rest not. (I would understand more if the code didn't work on all pages).

@@@EDIT I`m making my code at jupyter notebook localhost.

  • 2
    might be something to do with your local network settings, i'd contact your IT dept and ask them about any restrictions maybe you can't rapid fire requests ? – Umar.H Jun 30 '20 at 10:46
  • I will certainly write to the IT department, but can you explain me why for one website this code works correctly and I can read data but from other websites not? – Jakub Bidziński Jun 30 '20 at 11:03

2 Answers2

1

Checking the Proxy settings of your network and Check host IP/port settings may help. Check the following for already existing references in this regard:

errno-10061-no-connection

winerror-10061-no-connection-could-be-made

ConnectionRefusedError: [WinError 10061]

python-socket-programming-connectionrefusederror-winerror-10061

1

Check if the port you are using, unblocked by a firewall, or it's might be a misconfiguration issue, you may check if the port is open or not using socket package

import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

not_open = sock.connect_ex(('127.0.0.1',80))

if not_open == 0:
   print('Open')
else:
   print('Not Open')

sock.close()

If it's not open, then you may try the following, for linux-ubuntu, or Windows-10

4.Pi.n
  • 1,151
  • 6
  • 15