import json
import requests
import re
tag = "tag=mirai"
hd = {"Content-Type": "application/x-www-form-urlencoded"}
r = requests.post ('https://urlhaus-api.abuse.ch/v1/tag/', data=tag, headers=hd)
c = ['urls', 'url']
data = json.loads (r.text)
for i in range (0, 998):
fff = data['urls'][i]['url']
pattern = r"((([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])[ (\[]?(\.|dot)[ )\]]?){3}([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]))"
ips = [match[0] for match in re.findall (pattern, fff)]
list2 = []
for item in ips:
if item != []:
list2.append (item)
print(list2)
I wrote this code and output type list of lines I searching for 5 days throughout and any finds answer of problem.
Example output
['51.15.64.60']
['51.15.64.60']
['149.3.170.181']
['149.3.170.181']
['89.248.166.183']
['185.132.53.30']
['185.132.53.30']
['185.132.53.30']
Necessary output
['51.15.64.60']
['149.3.170.181']
['89.248.166.183']
['185.132.53.30']