I want to make a python script to take a screenshots of subdomains automatically when I give it a list of subdomains in text file.
First I learnt python basics then started searching for how to do this when I came to this code:
import requests
BASE = 'https://render-tron.appspot.com/screenshot/'
url = 'https://www.google.com'
path = 'target.jpg'
response = requests.get(BASE + url, stream=True)
# save file, see https://stackoverflow.com/a/13137873/7665691
if response.status_code == 200:
with open(path, 'wb') as file:
for chunk in response:
file.write(chunk)
But, as I said before, I want to give it a list of subdomains and check it one by one, so I edited this code to be:
import requests
BASE = 'https://render-tron.appspot.com/screenshot/'
url = open('s.txt','r')
path = 'target.jpg'
response = requests.get(BASE + url, stream=True)
# save file, see https://stackoverflow.com/a/13137873/7665691
if response.status_code == 200:
with open(path, 'wb') as file:
for chunk in response:
file.write(chunk)
But when I ran it it give me this error:
Traceback (most recent call last):
File "ping.py", line 7, in <module>
response = requests.get(BASE + url, stream=True)
TypeError: cannot concatenate 'str' and 'file' objects
and this is the code I ran:
import requests
BASE = 'https://render-tron.appspot.com/screenshot/'
url = open('s.txt','r')
path = 'target.jpg'
response = requests.get(BASE + url, stream=True)
# save file, see https://stackoverflow.com/a/13137873/7665691
if response.status_code == 200:
with open(path, 'wb') as file:
for chunk in response:
file.write(chunk)