I am working on a project to identify certain text in the body of Stack Overflow questions. It works but for this one case it is not working. I am looking to see if through code I can find exposed access keys for AWS to understand the gravity of the situation. Here is the code:
headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'en-US,en;q=0.5',
}
url = 'https://api.stackexchange.com/2.2/search/advanced?order=desc&sort=activity&body=' + 'AKIAIHXBFL3ATI64QPAQ' + '&site=stackoverflow'
req = urllib.request.Request(url, headers=headers)
response = urllib.request.urlopen(req)
time.sleep(3)
if response.info().get('Content-Encoding') == 'gzip':
pagedata = gzip.decompress(response.read())
elif response.info().get('Content-Encoding') == 'deflate':
pagedata = response.read()
elif response.info().get('Content-Encoding'):
print('Encoding type unknown')
else:
pagedata = response.read()
soup = BeautifulSoup(pagedata, "lxml")
print(soup)
Here is the response from soup:
<html><body><p>{"items":[],"has_more":false,"quota_max":300,"quota_remaining":291}</p></body></html>
It returns and empty file. If I search for other text in the body=**
parameter it does respond with a huge list of things. Am I doing something wrong or the API cannot do text search this specific?