mirror of
https://github.com/laramies/theHarvester.git
synced 2026-09-27 12:04:51 +02:00
improve search and display a message if IP is blocked by qwant
This commit is contained in:
@@ -29,20 +29,14 @@ class SearchQwant:
|
||||
return max(start, 0)
|
||||
|
||||
async def do_search(self) -> None:
|
||||
headers = {
|
||||
'Host': "api.qwant.com",
|
||||
'User-agent': Core.get_user_agent()
|
||||
}
|
||||
headers = {'User-agent': Core.get_user_agent()}
|
||||
|
||||
start = self.get_start_offset()
|
||||
limit = self.limit + start
|
||||
step = 10
|
||||
# https://help.qwant.com/help/qwant-search/searching/refine-search-with-operators/
|
||||
# during my tests I had better results with this operator
|
||||
word = f"«@{self.word}»"
|
||||
|
||||
api_urls = [
|
||||
f"https://api.qwant.com/api/search/web?count=10&offset={str(offset)}&q={word}&t=web&r=US&device=desktop&safesearch=0&locale=en_US&uiv=4"
|
||||
f"https://api.qwant.com/api/search/web?count=10&offset={str(offset)}&q={self.word}&t=web&r=US&device=desktop&safesearch=0&locale=en_US&uiv=4"
|
||||
for offset in range(start, limit, step)
|
||||
]
|
||||
|
||||
@@ -52,13 +46,17 @@ class SearchQwant:
|
||||
try:
|
||||
json_response = json.loads(response)
|
||||
except JSONDecodeError:
|
||||
# sometimes error 502 from server
|
||||
continue
|
||||
|
||||
try:
|
||||
response_items = json_response['data']['result']['items']
|
||||
except KeyError:
|
||||
# {"status":"error","error":24}
|
||||
# https://www.qwant.com/anti_robot
|
||||
if json_response.get("status", None) \
|
||||
and json_response.get("error", None) == 24:
|
||||
# https://www.qwant.com/anti_robot
|
||||
print("Rate limit reached - IP Blocked until captcha is solved")
|
||||
break
|
||||
continue
|
||||
|
||||
for response_item in response_items:
|
||||
|
||||
Reference in New Issue
Block a user