4
我只需要IP地址。如何報廢。我的代碼正確NOW-返回特定內容
import urllib
import urllib.request
from bs4 import BeautifulSoup
x = urllib.request.urlopen('http://bannedhackersips.blogspot.com/2014_08_04_archive.html')
soup = BeautifulSoup(x,"html.parser")
data = soup.find_all("ul", {"class": "posts"})
for content in data:
print(content.text)
輸出:
[Fail2Ban] SSH: banned 116.10.191.162
[Fail2Ban] SSH: banned 116.10.191.204
[Fail2Ban] SSH: banned 61.174.51.232
[Fail2Ban] SSH: banned 61.174.51.224
[Fail2Ban] SSH: banned 116.10.191.225
[Fail2Ban] SSH: banned 200.162.47.130
[Fail2Ban] SSH: banned 116.10.191.175
[Fail2Ban] SSH: banned 61.174.51.223
[Fail2Ban] SSH: banned 61.174.51.234
[Fail2Ban] SSH: banned 61.174.51.209
[Fail2Ban] SSH: banned 116.10.191.165
[Fail2Ban] SSH: banned 106.240.247.220