-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGetInsecamIP.py
47 lines (39 loc) · 1.54 KB
/
GetInsecamIP.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Insecam IP Scraper.
# Discord: L3#0001
from urllib.request import urlopen, Request
import urllib.request
import re
# File to write to
filename = "IP.txt"
# Regex to search for IP
regex = re.compile(r"(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})")
# HTTP Error 403: Forbidden without User Agent info. Add fake browser visit data.
headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) '
'AppleWebKit/537.11 (KHTML, like Gecko) '
'Chrome/23.0.1271.64 Safari/537.11',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'Accept-Encoding': 'none',
'Accept-Language': 'en-US,en;q=0.8',
'Connection': 'keep-alive'}
f = open(filename, "a")
# For each page 1 to x-1
for i in range(1,55):
# Change URL in " " to anything on www.insecam.org
#reg_url = f"http://www.insecam.org/en/bytype/Defeway/?page={i}"
reg_url = f"http://www.insecam.org/en/bytype/Foscam/?page={i}"
# Perform HTML Request
req = Request(url=reg_url, headers=headers)
# Get HTML Source
with urllib.request.urlopen(req) as response:
html = response.read().decode('utf-8')
#print(html)
# Perform regex on HTML Source to get IPs
list = re.findall(regex, html)
if list:
for ip, port in list:
print(ip + ":" + port)
f.write(ip + ":" + port +"\n")
else:
print("No IP Found on page " + i)
f.close()