Seçkin Üye
Şöyle bir kod yazdım. İlk denediğimde verileri aldı fakat 2.kez denediğimde bağlantı hatası verdi . Şimdi de siteye giremiyorum
ne yapmam lazım . Yapay zekaya sor demeyin , sordum .
Textile:
Traceback (most recent call last):
File "C:\Users\albur\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connection.py", line 174, in _new_conn
conn = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\albur\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\connection.py", line 95, in create_connection
raise err
File "C:\Users\albur\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] Bağlanılan uygun olarak belli bir süre içinde yanıt vermediğinden veya kurulan
bağlantı bağlanılan ana bilgisayar yanıt vermediğinden bir bağlantı kurulamadı
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\albur\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\albur\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\albur\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "C:\Users\albur\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connection.py", line 363, in connect
self.sock = conn = self._new_conn()
^^^^^^^^^^^^^^^^
File "C:\Users\albur\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connection.py", line 179, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x000002767F916410>, 'Connection to www.vesselfinder.com timed out. (connect timeout=None)')
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='www.vesselfinder.com', port=443): Max retries exceeded with url: //vessels/details/9077549 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000002767F916410>, 'Connection to www.vesselfinder.com timed out. (connect timeout=None)'))
Python:
def shipsfeature():
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
}
dosya_adı= "shiplinks.txt"
dosya_adı1= "shipsfeatures.txt"
with open(dosya_adı, "r") as shiplinks:
with open(dosya_adı1, "w") as shipsfeatures:
ships = shiplinks.readlines()
for ship in ships:
response = requests.get(ship.strip(), headers=headers)
if response.status_code == 200:
soup = BeautifulSoup(response.content, "html.parser")
headlines =soup.find_all(class_="n3")
values =soup.find_all(class_="v3")
n = 1
while n<928:
if n % 2 ==0:
values_text =[value.get_text() for value in values]
shipsfeatures.write(" , ".join(values_text)+ "\n")
else:
headlines_text= [headline.get_Text() for headline in headlines]
shipsfeatures.write(" , ".join(headlines_text) + "\n")
n += 1
else:
print(f"Hata: {response.status_code} - İstek başarısız.")
Son düzenleme: