I tried to crawl the next news, but I got a timeout error So I typed the code one by one and looked for the error, and I got a timeout error in urlib.request.urlopen, but I don't know why it's showing up How can I crawl? crying Code is
import urllib.request
import urllib.parse
from bs4 import BeautifulSoup
url="http://search.daum.net/search?w=news&q=GIA%EB%8B%A4%EC%9D%B4%EC%95%84%EB%AA%AC%EB%93%9C&spacing=0&p=1&DA=PGD"
req=urllib.request.Request(url)
res=urllib.request.urlopen(req)
The error is
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
res=urllib.request.urlopen(req)
File "C:\Python34\lib\urllib\request.py", line 161, in urlopen
return opener.open(url, data, timeout)
File "C:\Python34\lib\urllib\request.py", line 464, in open
response = self._open(req, data)
File "C:\Python34\lib\urllib\request.py", line 482, in _open
'_open', req)
File "C:\Python34\lib\urllib\request.py", line 442, in _call_chain
result = func(*args)
File "C:\Python34\lib\urllib\request.py", line 1211, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Python34\lib\urllib\request.py", line 1186, in do_open
r = h.getresponse()
File "C:\Python34\lib\http\client.py", line 1227, in getresponse
response.begin()
File "C:\Python34\lib\http\client.py", line 386, in begin
version, status, reason = self._read_status()
File "C:\Python34\lib\http\client.py", line 348, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Python34\lib\socket.py", line 378, in readinto
return self._sock.recv_into(b)
TimeoutError: [WinError 10060] Connection failed because there was no response from the connected member, or the connection was disconnected because there was no response from the host
It's coming up like this. Help me ㅠ<
python crawling scraping urllib timeout
For me,
import urllib.parse
url="http://search.daum.net/search?w=news&q=GIA%EB%8B%A4%EC%9D%B4%EC%95%84%EB%AA%AC%EB%93%9C&spacing=0&p=1&DA=PGD"
req=urllib.request.Request(url)
res=urllib.request.urlopen(req)
When I ran , there was no problem.
The Timeout error means that tried to connect, but could not connect within a set time.
It seems that the internet connection was disconnected when the code was turned, or the connection was not stable for a while.
Try turning the code again.
© 2024 OneMinuteCode. All rights reserved.