第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

http.client.InvalidURL: nonnumeric port:

http.client.InvalidURL: nonnumeric port:

楊魅力 2022-08-02 16:13:50
我一直在嘗試制作一個(gè)腳本來檢查是否存在隨機(jī)網(wǎng)站,如果它確實(shí)存在,則打開它,但我不斷收到一堆不同的錯(cuò)誤。這是我的代碼:import webbrowserimport timeimport randomimport http.clientfrom random_word import RandomWordsr=RandomWords()while True:    possible_things = random.choice([".com",".net"])    WEB = "http://"+r.get_random_word()+possible_things    c = http.client.HTTPConnection(WEB)    if c.getresponse().status == 200:        seconds = random.randint(5,20)        print("Web site exists; Website: "+WEB+" ; Seconds: "+seconds)        time.sleep(seconds)        webbrowser.open(WEB)        print("Finished countdown, re-looping...")    else:        print('Web site DOES NOT exists; Website: '+WEB+'; re-looping...')這是錯(cuò)誤:Traceback (most recent call last):  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 877, in _get_hostport    port = int(host[i+1:])ValueError: invalid literal for int() with base 10: '//water-lined.net'During handling of the above exception, another exception occurred:Traceback (most recent call last):  File "Troll.py", line 10, in <module>    c = http.client.HTTPConnection(WEB)  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 841, in __init__    (self.host, self.port) = self._get_hostport(host, port)  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 882, in _get_hostport    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])http.client.InvalidURL: nonnumeric port: '//water-lined.net'
查看完整描述

2 回答

?
慕碼人8056858

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超6個(gè)贊

我只是設(shè)置了很長的延遲并添加了很多嘗試,但是非常感謝@B ?otosm?tek!


查看完整回答
反對 回復(fù) 2022-08-02
?
郎朗坤

TA貢獻(xiàn)1921條經(jīng)驗(yàn) 獲得超9個(gè)贊

WEB = "http://"+r.get_random_word()+possible_things

c = http.client.HTTPConnection(WEB)

在第一行中,您創(chuàng)建一個(gè) URL,從 http:// 在第二行中,您將它傳遞給一個(gè)函數(shù),該函數(shù)不需要 URL,而是一個(gè)具有可選和端口號的主機(jī)名。由于您的字符串在“http”之后包含冒號,因此“http”將被假定為主機(jī)名,冒號之后的所有內(nèi)容,即'//something.tld'被解釋為端口號 - 但它不能轉(zhuǎn)換為整數(shù),因此錯(cuò)誤。:


你可能想做的是沿著以下路線:


host = r.get_random_word() + possible_things

WEB = 'http://' + host

c = http.client.HTTPConnection(host)

c.request('GET', '/')

resp = c.getresponse()

if resp.status == 200:

等。


查看完整回答
反對 回復(fù) 2022-08-02
  • 2 回答
  • 0 關(guān)注
  • 614 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號