Все, что я пытаюсь сделать, это сначала получить список ссылок всех тегов привязки, а затем очистить текст таблиц от каждого из этих очищенных списков. Но все, что я получаю, это ошибка. Кто-нибудь может мне помочь?
Мой код:
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as uReq
import csv
from datetime import datetime
pages = []
my_url = 'https://deltaimmigration.com.au/Australia-jobs/'
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")
col = page_soup.find('td', width="250")
# rows = table.find_all('tr')
# print(len(col))
# print(col.text)
filename = "links.txt"
f = open(filename,'w')
headers = "Link of all jobs "
f.write(headers)
for a in col.find_all('a', href=True):
link= a['href']
f_link = link.replace(".." , "https://deltaimmigration.com.au")
pages.append(f_link)
for items in pages:
tables = items.find('table', width="900")
table = tables[0]
for table in tables:
rows_tables = table.tbody.find_all('tr')
rows = rows_tables[0].text
for row in rows:
print(row.text)
f.close()
Может кто-нибудь помочь мне решить эту проблему? Разве мы не можем соскрести данные со скребущих ссылок с той же страницы? Ошибка:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "e:/scrape/link.py", line 8, in <module>
uClient = uReq(my_url)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 543, in _open
'_open', req)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 1360, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 1319, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10054] An existing connection was forcibly closed by the remote host>
user@Bidhya-1s MINGW64 /e/scrape
$ C:/Users/user/Anaconda3/python.exe e:/scrape/link.py
Traceback (most recent call last):
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 1317, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "C:\Users\user\Anaconda3\lib\http\client.py", line 1244, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\user\Anaconda3\lib\http\client.py", line 1290, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\user\Anaconda3\lib\http\client.py", line 1239, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\user\Anaconda3\lib\http\client.py", line 1026, in _send_output
self.send(msg)
File "C:\Users\user\Anaconda3\lib\http\client.py", line 966, in send
self.connect()
File "C:\Users\user\Anaconda3\lib\http\client.py", line 1414, in connect
server_hostname=server_hostname)
File "C:\Users\user\Anaconda3\lib\ssl.py", line 423, in wrap_socket
session=session
File "C:\Users\user\Anaconda3\lib\ssl.py", line 870, in _create
self.do_handshake()
File "C:\Users\user\Anaconda3\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "e:/scrape/link.py", line 8, in <module>
uClient = uReq(my_url)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 543, in _open
'_open', req)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 1360, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\Users\user\Anaconda3\lib\urllib\request.py", line 1319, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10054] An existing connection was forcibly closed by the remote host>
'' '